I am using MySQL 5.1 hosted by my provider. This is my request.
mysql_query(" IF EXISTS(SELECT * FROM licensing_active WHERE title_1='$title_1') THEN BEGIN UPDATE licensing_active SET time='$time' WHERE title_1='$title_1') END ELSE BEGIN INSERT INTO licensing_active(title_1) VALUES('$title_1') END ") or die(mysql_error());
Mistake
... check the manual that corresponds to your MySQL server version for the right syntax to use near 'IF EXISTS(SELECT * FROM licensing_active WHERE title_1='Title1') THEN ' at line 1
My actual task includes
WHERE title_1='$title_1' AND title_2='$title_2' AND version='$version' ...ETC...
but I reduced it to simplify the solution to the problem.
In my searches on this subject, I see links to "ON DUPLICATE KEY UPDATE", but I donβt know what to do about it.
Openstar63
source share