vendredi 21 juillet 2017

Can I use IF in an SQL sentence in MySQL?

UPDATE `order` SET `status` = IF `type` = 2 THEN 1 ELSE 2 END IF;

I wrote this sentence in a MySQL trigger, and I got this error prompt:

Error Code: 1064 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 'type = 2 THEN 1 ELSE 2 END IF at line 5

How can I fix this error?

Aucun commentaire:

Enregistrer un commentaire