CASE附近的MySQL无法识别的关键字

前端之家收集整理的这篇文章主要介绍了CASE附近的MySQL无法识别的关键字前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

我遇到了PHPmyadmin 4.6.4的问题,这似乎与这两个问题完全相同:

> https://github.com/phpmyadmin/phpmyadmin/issues/12100
> MySQL “ALL” statement not working in phpmyadmin

根据这些,似乎这个问题在这个版本中被解决了,但是我仍然在这个代码上收到相同的错误列表.这是代码

PHPmyadmin中执行以下SQL查询

select (SELECT name FROM MysqL.help_category WHERE help_category_id = 1) as name,case when country = "India" then 1 else 0 end as country_flag 
FROM ( select "India" as country ) a;

得到这些错误

An expression was expected. (near “case” at position 91) Unrecognized
keyword. (near “case” at position 91) Unrecognized keyword. (near
“when” at position 96) Unexpected token. (near “country” at position
101) Unexpected token. (near “=” at position 109) Unexpected token.
(near “‘India'” at position 111) Unrecognized keyword. (near “then” at
position 119) Unexpected token. (near “1” at position 124)
Unrecognized keyword. (near “else” at position 126) Unexpected token.
(near “0” at position 131) Unrecognized keyword. (near “end” at
position 133) Unrecognized keyword. (near “as” at position 137)
Unexpected token. (near “country_flag” at position 140) An expression
was expected. (near “(” at position 159) Unexpected token. (near “(”
at position 159)

我在WIndows10上通过WAMP64 3.0.6运行PHPmyadmin 4.6.4.任何想法将不胜感激!

谢谢

最佳答案
我遇到了与case语法相同的错误消息.你可以简单地在PHPMyAdmin中的case语句周围添加()来执行它.

选择(SELECT name FROM MysqL.help_category WHERE help_category_id = 1)作为名称,(例如country =“India”然后1 else 0结束时)作为country_flag FROM a;

猜你在找的MySQL相关文章