简体   繁体   English

MySQL查询正在搜索列名而不是值

[英]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 `cityName`,
    `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%); 我想找到没有回答问题的单位(搜索“ pesquisaRH”表时计数为0的点),并在其类别名称(%central%,%DPM%,%DPC)中具有四种指定模式之一%或%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! 您使用了错误的报价!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM