mysql query – error: 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 ‘a’, ‘1’) ON DUPLICATE KEY UPDATE count=count+1′ at line 1
The query that fails:
INSERT INTO tags (ip, tag, count)
VALUES ('xx.xx.xxx.xxx', 'krwiopijcy', '1')
ON DUPLICATE KEY UPDATE count=count+1;
Is there anything wrong in my query?
countis a built in function and as such, may require care to be used as such. However, as the docs say, it is perfectly fine as column name. You might want to escape it usingThat being said, I had no problem with your exact query (no escaping) using this table structure:
Your example from the comments has one apostrophe too much (behind ‘umacku’), which doesn’t seem to be the problem (as it is not given in the error message), but you should paste the exact queries: