这是我在 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
这样的条件或 var<2
.
关于mysql - MySQL触发器中的IF语句,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30187129/