Mysql LIKE查询不起作用

时间:2013-05-29 15:20:19

标签: php mysql mysql-error-1064

所以我正在尝试这样的基本查询:

SELECT `City`.* FROM `city` WHERE (City 'LIKE %a%') 

但是我得到了这个错误:

#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 ''LIKE %a%') LIMIT 0, 30' at line 1

我想我错过了什么!

1 个答案:

答案 0 :(得分:8)

SELECT `City`.* FROM `city` WHERE (City LIKE '%a%')

您没有正确使用单引号。

是:

City LIKE '%a%'

City 'LIKE %a%'