为什么我得到错误:
#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
询问:
IF EXISTS(SELECT id FROM mytable WHERE id = '1')
谢谢
IF EXISTS仅适用于存储过程。在存储过程之外,IF()是一个带有3个参数的函数。正确的用法是
IF EXISTS
IF()
SELECT IF(EXISTS(SELECT `column` FROM `table` WHERE `id` = `1`), 1, 0);