UPDATE in SQL, and Decrementing

admin

Administrator
Staff member
Basically I have a database of users that are group in Alliances. (I am working on an online game) When the user leaves the Alliance I want to decrease the members value that is stored in the Alliance table by one. So I cycle through the rows til I reach the right Alliance. My question is can I just do something like
--------
UPDATE alliance
SET
members = members-1,
WHERE
id=/"$alli/"
--------
or do I have to load the original value through one SQL statement and then subtract one and then insert it into the table?

I am relatively new to PHP so I am a bit confused on how to get this to work.
 
Back
Top