语法错误MySQL IF EXISTS

时间:2015-06-17 07:50:32

标签: mysql if-statement subquery

我有投票的SQL查询,检查投票是否存在,但它一直给我语法错误

IF EXISTS (SELECT * FROM `votes` WHERE `id` = 298 AND `author` = 'noo

子查询本身运行良好。

IF EXISTS (SELECT * FROM `votes` WHERE `id` = 298 AND `author` = 'noob') THEN
    'exist'
ELSE
    INSERT INTO `votes`(`id`, `author`, `type`, `value`) VALUES (298, "noob", "upvote", 1)
    'upvoted'
END IF

0 个答案:

没有答案