According to this article ( http://blogs.msdn.com/b/miah/archive/2008/02/17/sql-if-exists-update-else-insert.aspx ) I would like to do something like this:
UPDATE chunks SET targets = CONCAT(targets, ",phpValue1")
WHERE scopeX=phpValue2 AND scopeY=phpValue3;
IF ROW_COUNT() = 0
INSERT INTO chunks (scopeX, scopeY, targets) VALUES (phpValue2,phpValue3,phpValue1)
But then I receive this 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 'IF ROW_COUNT() = 0 INSERT INTO chunks (scopeX, scopeY, targets)
I also tried with "THEN" after the condition but it didn't work either. What also might be interesting is that I am working with the newest Version of XAMPP, I think, which still uses MySQL 5.0, when I looked it up correctly.
for sure phpValue* is inserted by php correctly thank you very much for any help =)
You can't use control statements like if
without a function around it. You have to put that in a function, procedure, trigger or event.