SA-MP Forums Archive
MySQL: SELECT FOR UPDATE - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: MySQL: SELECT FOR UPDATE (/showthread.php?tid=294652)



MySQL: SELECT FOR UPDATE - LeNy - 02.11.2011

Hello. I want to do a conditional instructions with a SELECT FOR UPDATE. My query looks like this:
pawn Код:
SELECT `Duty` FROM `Employees` WHERE `UID` = '1' FOR UPDATE;
UPDATE `Employees` SET `Duty`
And here I have a question how to develop the condition if the player has a duty == 0 then set on duty == 1 and vice versa?

//EDIT:
I tried with:
pawn Код:
UPDATE `Employees` IF(`Duty` == '1' SET `Duty` = '0' OR `Duty` == '0' SET `Duty` = '1')
but it does not work


Re: MySQL: SELECT FOR UPDATE - AndreT - 02.11.2011

You could try something like what's described in this article.

Putting 2 queries in one mysql_query won't work by the way!