Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > MySQL
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old November 8th, 2006, 06:33 AM
Authorized User
 
Join Date: Jul 2004
Location: rajshahi, , Bangladesh.
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
Reply With Quote
  #2 (permalink)  
Old November 8th, 2006, 07:43 AM
Friend of Wrox
 
Join Date: Jul 2003
Location: , , United Kingdom.
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
Default

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

Chris

Reply With Quote
  #3 (permalink)  
Old November 8th, 2006, 09:22 AM
Authorized User
 
Join Date: Jul 2004
Location: rajshahi, , Bangladesh.
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
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding the records into Field F1 while importing a jcui@bankofny.com VB Databases Basics 0 August 6th, 2004 01:43 PM
Adding the records into Field F1 while importing a jcui@bankofny.com 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



All times are GMT -4. The time now is 02:19 PM.


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