Re: Best way to increment an integer column in mysql

From: Date: Thu, 11 Dec 2003 11:22:10 +0000
Subject: Re: Best way to increment an integer column in mysql
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-172458@lists.php.net to get a copy of this message
John - ..and then John Clegg said... % % I was wondering if there is a php / mysql function call that will % increment an integer column in a database. % ie. the equivalent to % $foo++; I didn't see that, but you can at least let mysql do the math: update tablename set field = field + 1 where condition Just make sure you don't forget "where condition" :-) And beware that if you have a timestamp field in the table you'll need to set it to itself in order to avoid updating it. % % Cheers % % John Clegg HTH & HAND :-D -- David T-G * There is too much animal courage in (play) davidtg@justpickone.org * society and not sufficient moral courage. (work) davidtgwork@justpickone.org -- Mary Baker Eddy, "Science and Health" http://justpickone.org/davidtg/ Shpx gur Pbzzhavpngvbaf Qrprapl Npg!

« previous php.general (#172458) next »