IF syntax error

空扰寡人 提交于 2019-12-01 18:21:59

Your query is only valid in a stored procedure/function context. See there for reference.

using if statements like this is valid only inside stored procedure or functions.

What you'd probably like to use is the if() function, and then you can use:

select IF(0=0, 'hello world','');

If statements are not supported in general SQL flow. It can only be used in functions or procedures. However you can use it in following way

use my_db;
delimiter #
create procedure xyz()
 begin
   IF 0=0 then select 'hello world';
 end if;
end#
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!