MySQL触发器中的IF语句

MySQL触发器中的IF语句,mysql,if-statement,triggers,Mysql,If Statement,Triggers,这是我在MySQL触发器中的查询代码 if 1=2 then select 'Yes'; else select 'No'; end if; 但有以下错误: if '1'='2' then select 'Yes' Error Code: 1064. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the rig

这是我在MySQL触发器中的查询代码

if 1=2 then
    select 'Yes';
else
    select 'No';
end if;
但有以下错误:

if '1'='2' then    select 'Yes' 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 'if '1'='2' then    select 'Yes'' at line 1 0.000 sec

解决方案是什么?

MySQL中If语句的正确语法是

IF (Expression) THEN
               body;
ELSE
           body;
END IF;
此外,1=2不是一个表达式
它必须是一些条件,如var>1或varProblem必须在if之前的语句中。。。陈述您最好发布触发器正文。我的问题只是这个代码发布完整的触发器代码。@user2545982:发布的代码没有错误。通常错误堆栈显示一个语句点,在此点之前存在错误。例如:。。。对于用户*near*'的正确语法,如果“1”=。。。