PDA

View Full Version : Update a cell's value with MySQL numerical ops


guvenck
04-24-2008, 12:07 PM
Hello,

I keep a counter of my pages in MySQL. What I am doing is to read the current value, add 1 to it and then update the db field with the new value, all with PHP.

I wonder, if this could be done with a single MySQL query, using MySQL numerical operators.

abduraooft
04-24-2008, 01:45 PM
http://dev.mysql.com/doc/refman/5.0/en/update.html
UPDATE persondata SET age=age+1;

guvenck
04-24-2008, 02:20 PM
That is exactly what I've expected. Thank you very much!