SQL语法错误选择Where Like

时间:2015-11-11 08:07:40

标签: mysql select syntax where sql-like

我的phpmyadmin给了我以下错误:

#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 '17, COL 19, COL 21, COL 23
FROM `table 1`
WHERE (COL 7
LIKE '%13%' OR COL ' at line 1 

当我尝试这样打电话时:

SELECT COL 17, COL 19, COL 21, COL 23 
FROM `table 1` 
WHERE (COL 7 
LIKE '%13%' OR COL 1 
LIKE '%13%' OR COL 2 
LIKE '%13%' OR COLE 3 
LIKE '%13%')

我尝试了几个选项,但没有用,我可能会监督某些事情,但找不到它。

1 个答案:

答案 0 :(得分:1)

尝试在单个反引号中添加列名称(似乎在其中包含空格):

SELECT `COL 17`, `COL 19`, `COL 21`, `COL 23`
FROM `table 1` 
WHERE (`COL 7` LIKE '%13%' OR `COL 1` LIKE '%13%' OR `COL 2` LIKE '%13%'
    OR `COL 3` LIKE '%13%')