Query syntax
#1

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' 
Reply
#2

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)