开发者

Mysql Query is searching for column name instead of value

What's wrong with this query?

SELECT
    `category`,
    (
        SELECT `name`
        FROM `city_names`
        WHERE `city_code`=`units`.`city_code`
    )as `cit开发者_如何学运维yName`,
    `email`
FROM
    `units`
WHERE
    (
        SELECT COUNT(*) 
        FROM `pesquisaRH` 
        WHERE `unit_code` = `units`.`unit_code`
    )=0 AND
    (
        (`category` LIKE `%central%`) OR 
        (`category` LIKE `%DPM%`) OR 
        (`category` LIKE `%DPC%`) OR  
        (`category` LIKE `%DIC%`)
    )

It returns me this error:

#1054 - Coluna '%central%' desconhecida em 'where clause'

It seems to be searching for the patterns in the column name instead of its value.

I want to find the units that didn't answer a questionary (the ondes that count 0 when searching the "pesquisaRH" table) AND have one of the four specifyed patterns in their category names (%central%, %DPM%, %DPC% or %DIC%); and then, return their category, the name of the city they're located and their email.


`%central%` should be '%central%'

`%DPM%` should be '%DPM%'

... and so on. You're using the wrong kind of quote!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜