Click to See Complete Forum and Search --> : Is there a var = var++ type thing in MYSQL?


xvszero
02-29-2008, 01:28 PM
I just realized I'm doing things a very stupid way, when I want to say... add a page hit to my overall counter I user a select to grab the current one, and then php to increment it and then an update to change to the new one. But I'd imagine there has to be something along the lines of...

update TABLENAME set var=var+1

Is this possible in MYSQL?

scragar
02-29-2008, 01:32 PM
you'd want a where cause to indicate what result your editing, but that's spot on

UPDATE tablename SET field=field+1 WHERE condition

xvszero
02-29-2008, 02:10 PM
Ah yeah I figured it had to be in there. Sweet.