Why I'm getting this error:
#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
'IF EXISTS(SELECT id FROM mytable WHERE id = '1')' at line 1
My SQL query:
IF EXISTS(SELECT id FROM mytable WHERE id = '1')
Thanks.
IF EXISTS
only works in a stored procedure. Outside of a stored procedure, IF()
is a function which takes 3 arguments. Proper usage would be
SELECT IF(EXISTS(SELECT `column` FROM `table` WHERE `id` = `1`), 1, 0);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With