Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL Unrecognized Keyword near CASE

I'm having an issue with phpmyadmin 4.6.4 that seems to be identical to these two issues:

  • https://github.com/phpmyadmin/phpmyadmin/issues/12100

  • MySQL "ALL" statement not working in phpmyadmin

According to these, it seems this problem was allegedly fixed in this release, but I'm still receiving the identical list of errors on this code. Here's the code:

Execute below SQL query in phpmyadmin

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;

Getting these errors:

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)

I'm running phpmyadmin 4.6.4 through WAMP64 3.0.6 on WIndows10. Any thoughts would be greatly appreciated!

Thanks

like image 375
Flint Hasset Avatar asked Nov 02 '16 21:11

Flint Hasset


1 Answers

I had encountered same error message with case syntax. You can simply add ( ) around case statement in PhpMyAdmin to execute it.

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 a;

like image 169
Devang Avatar answered Sep 30 '22 22:09

Devang