Can anybody help me in this syntax? I don't know what wrong am I doing!
When I try to execute this code:
IF EXISTS(SELECT * FROM user WHERE user_username = '$user_username')
THEN
UPDATE user SET user_name='$name',user_profession='$profession',user_address='$address',user_avatar='$NewImageName'
ELSE
INSERT INTO user (user_name,user_profession,user_address,user_avatar) VALUES ('$name','$profession','$address','$NewImageName';
I get the following 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 EXISTS(SELECT * FROM user WHERE user_username = '111') THEN UPDATE user SE' at line 1
I don't know what is wrong with this code!
insert .. on duplicate key updatesyntaxUPDATEthe table when theIF EXISTSpart is TRUE. Else, I wanted toINSERTinto the table.ON DUPLICATEkey.