问题:
The script for checking multiple condition on SQL as follow, which I have tried.
BEGIN
IF @total == 7 THEN
UPDATE some_table SET time = '09:55' where warehouse_id=@code...
可以将文章内容翻译成中文,广告屏蔽插件会导致该功能失效:
问题:
The script for checking multiple condition on SQL as follow, which I have tried.
BEGIN
IF @total == 7 THEN
UPDATE some_table SET time = '09:55' where warehouse_id=@code;
UPDATE some_table SET enable = 0 where warehouse_id=@code;
SELECT * FROM some_table WHERE warehouse_id= @code;
END IF
END
Here the value of @total is 7 but the script is not able to executing and says
[42000][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 @total == 7 THEN' at line 2
回答1:
Mysql IF ... ELSE
only support for stored procedure
or trigger
You can try to move logic @total = 7
in where
caluse.
UPDATE some_table SET time = '09:55' where warehouse_id=@code and @total = 7;
UPDATE some_table SET enable = 0 where warehouse_id=@code and @total = 7;
SELECT * FROM some_table WHERE warehouse_id= @code and @total = 7;
回答2:
try with this
IF @total = 7 THEN
just change single '= '
回答3:
you should change the equal operator to = , it will be like this :
IF @total = 7 THEN ..