mysql - 如果语法错误

标签 mysql sql if-statement syntax syntax-error

我在遵循 MySQL 的 IF 语法指南时遇到语法错误。

我的查询是:

if 0=0 then select 'hello world'; end if;

从逻辑上讲,这应该选择 'hello world',但我却得到了

ERROR 1064 (42000): 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 (0=0) then select 'hello world'' at line 1
ERROR 1064 (42000): 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 'end if' at line 1

最佳答案

您的查询仅在存储过程/函数上下文中有效。 参见 there供引用。

关于mysql - 如果语法错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35366493/

相关文章:

Mysql 索引不起作用

mysql - 新手 : mysql join 2 tables to gether and count the results

python - 如果函数在匹配来自不同列表的两个用户 ID 时执行函数?

iphone - Objective-C If 语句比较 float 不起作用

PHP:切换与如果

java - 禁用 dbcp 连接池的重试

PHP MySQL - 如何每周随机选择项目?

MySQL 选择计数

sql - PostgreSQL 数据库中的阿拉伯文和英文文本

mysql - 条件mysql if内连接