Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > MySQL
|
MySQL General discussion about the MySQL database.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the MySQL section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 8th, 2006, 06:33 AM
Authorized User
 
Join Date: Jul 2004
Posts: 79
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to rajuru Send a message via Yahoo to rajuru
Default adding value to field

Dear, I need to increase a field. suppose hits. I want to update the value of hits field by 1 each time a visitor views a content.
i tried this subquery
update stats set views=(select views from stats where id=3)+1 where id=3
but i saw this error message:
#1093 - You can't specify target table 'stats' for update in FROM clause

i don't want to fetch value and add 1 with it then update the database. If i can do this by a simple statement, it will be great.


Best Regard:
Md. Zakir Hossain (Raju)

www.rajuru.xenexbd.com - my blog with PHP scripts, PHP Book Review and many more
__________________
Best Regard:
Md. Zakir Hossain (Raju)

www.rajuru.xenexbd.com - my blog with PHP scripts, PHP Book Review and many more
 
Old November 8th, 2006, 07:43 AM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
Default

Code:
UPDATE stats SET views = views + 1 WHERE id = 3;
HTH,

Chris

 
Old November 8th, 2006, 09:22 AM
Authorized User
 
Join Date: Jul 2004
Posts: 79
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to rajuru Send a message via Yahoo to rajuru
Default

thanks a lot, it worked

Best Regard:
Md. Zakir Hossain (Raju)

www.rajuru.xenexbd.com - my blog with PHP scripts, PHP Book Review and many more





Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding the records into Field F1 while importing a [email protected] VB Databases Basics 0 August 6th, 2004 01:43 PM
Adding the records into Field F1 while importing a [email protected] Access 0 August 6th, 2004 01:06 PM
Automate adding record and populating field bmurrin Access 3 January 29th, 2004 12:25 PM
Adding a date to a memo field mikericc Access VBA 2 November 25th, 2003 10:35 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.