Click to See Complete Forum and Search --> : mySQL additon


esm
02-13-2008, 12:22 PM
fortunately (for me), most of my interaction with sql is simple queries (selects, updates, deletes). but i do have one statement that I have a question about

the code is$query="UPDATE mytable SET counter=counter+$number WHERE account=$account";

sometimes $number is positive and sometimes it is negative.

the PHP code then (sometimes) evaluates to$query="UPDATE mytable SET counter=counter+-1 WHERE account=1234";

so, my question is: Is "counter+-1" acceptable in mySQL...??? it seems to work. just looks strange.



.

chazzy
02-13-2008, 01:14 PM
the order of operations says that the - before the 1 resolves the number to a negative.