Myy*_*Myy 4 mysql if-statement
我试图使这个If Statement工作,但我似乎无法让它做我想要的.如果我选择@result,它会给我值0,那么为什么IF语句不起作用?
SET @message = '((sometihng here))';
select LEFT(@message, 1) into @firstChar;
select STRCMP(@firstChar,'(') into @result;
IF (@result = 0) THEN
SET @message = 'true';
//more selects and cals here;
END IF;
select @message;
Run Code Online (Sandbox Code Playgroud)
我应该成真,但我没有告诉我一个错误:
SQL query: IF( @result =0 ) THEN SET @message = 'true';
MySQL说:
1064 - 您的SQL语法出错; 检查与MySQL服务器版本对应的手册,以便在第1行的"IF(@result = 0)THEN SET @message ='true''附近使用正确的语法
尝试使用功能http://dev.mysql.com/doc/refman/5.0/en/control-flow-functions.html#function_if
SELECT IF(@result = 0, 'true', '((something here))') AS message
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
18621 次 |
| 最近记录: |