SA-MP Forums Archive
Query syntax - 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: Query syntax (/showthread.php?tid=648454)



Query syntax - Meller - 22.01.2018

I can't seem to find out the syntax error, I've had like a ton of this specific query give me a syntax error since I wrote it.

Код:
[20:13:44] [ERROR] error #1064 while executing query "IF EXISTS (SELECT * FROM inventories WHERE id = '1' AND accountid = '1') UPDATE inventories SET item = '1', amount = '1', extra = '0' WHERE id = '1' AND accountid = '1' ELSE INSERT INTO inventories VALUES accountid = '1', item = '1', amount = '1', extra = '1'": You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'UPDATE inventories SET item = '1', amount = '1', extra = '0' WHERE id = '1' AND ' at line 1
PHP код:
IF EXISTS (SELECT FROM inventories WHERE id '1' AND accountid '1')
UPDATE inventories SET item '1'amount '1'extra '0' WHERE id '1' AND accountid '1' 
ELSE INSERT INTO inventories VALUES accountid '1'item '1'amount '1'extra '1' 



Re: Query syntax - BroZeus - 22.01.2018

In MySQL IF statements cannot exist outside stored procedure. A better solution for doing this would be to make a column unique then using this.