I have a query like this:
IF EXISTS(SELECT 1 FROM table1 WHERE col1 = ? LIMIT 1) THEN DELETE FROM table2 WHERE col2 = ? END IF
But I do not know why the above request does not work. Also this does not work either:
IF EXISTS(SELECT 1 FROM table1 WHERE col1 = ? LIMIT 1) BEGIN DELETE FROM table2 WHERE col2 = ? END
MySQL will tell me that there is a syntax error, how can I fix it?
source share