increase MySQL field value by 1? (quickly/easily)
am 21.11.2005 13:11:48 von John McClumpha
Hi there - just a quick query (pardon the pun)...
is there a simple (quick) way to increase the value of an integer
field in a nominated row by 1 other than first having to retrieve the
value and then UPDATE the appropriate field? - similar to doing a
$Variable++ in PHP?
Thanks in advance
--
John McClumpha
Darkness Reigns - http://www.incitegraphics.com.au/darkness/
Re: increase MySQL field value by 1? (quickly/easily)
am 21.11.2005 13:38:20 von Rob
Sure, increase it in the update query, example:
UPDATE hit SET counter+1 WHERE site='www.google.com'
(assuming that counter field is integer)
John McClumpha schreef:
> Hi there - just a quick query (pardon the pun)...
>
> is there a simple (quick) way to increase the value of an integer
> field in a nominated row by 1 other than first having to retrieve the
> value and then UPDATE the appropriate field? - similar to doing a
> $Variable++ in PHP?
>
> Thanks in advance
>
> --
> John McClumpha
> Darkness Reigns - http://www.incitegraphics.com.au/darkness/
Re: increase MySQL field value by 1? (quickly/easily)
am 21.11.2005 14:36:08 von Stefan Rybacki
rob@centralpoint.nl wrote:
> Sure, increase it in the update query, example:
> UPDATE hit SET counter+1 WHERE site='www.google.com'
> (assuming that counter field is integer)
Well, should be:
UPDATE hit SET counter=counter+1 WHERE site='www.google.com'
Regards
Stefan
>...
Re: increase MySQL field value by 1? (quickly/easily)
am 21.11.2005 22:45:34 von Pat Farrell
John McClumpha wrote:
> is there a simple (quick) way to increase the value of an integer
> field in a nominated row by 1 other than first having to retrieve the
> value and then UPDATE the appropriate field? - similar to doing a
> $Variable++ in PHP?
Why not use the autoincrement feature of MySql?
--
Pat