SA-MP Forums Archive
MySQL syntax error - 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 syntax error (/showthread.php?tid=596413)



MySQL syntax error - Riddick94 - 17.12.2015

I have never liked using if statements in mysql queries but to let myself avoid formatting query couple of times in a code with default PAWN if statements I wanted to move into into one MySQL query.

pawn Код:
UPDATE `items_data` IF((`model` >= 15077 AND `model` <= 15084) THEN IF((`quantity` + %d) > 3) SET `quantity` = 3) ELSE SET `quantity` = `quantity` + %d WHERE `model` = %d AND `owner_uid` = %d
I am having an MySQL Syntax Error, and I really don't know how to fix it up. It's probably related to "THEN IF", I guess.

Код:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'IF((`model` >= 15077 AND `model` <= 15084) THEN IF(`quantity` + 3 > 3) SET `quan' at line 1
Thanks.