-2

存在的列的 HAVING 子句有问题

SELECT COUNT(*) AS `numrows`
FROM (`customers`)
LEFT JOIN `parent_companies` AS j2ee39a6a ON `j2ee39a6a`.`id` = `customers`.`parent_company_id`
WHERE `customers`.`is_approved` =  0
AND  `organization`  LIKE '%Pizza%'
OR  `title`  LIKE '%Pizza%'
OR  `picture`  LIKE '%Pizza%'
HAVING `customers`.`is_approved` = 0

我真的不明白为什么它应该有这样的问题 - 这是由 Grocerycrud 生成的查询 - 自动..用于搜索特定输出..

4

1 回答 1

0

HAVING是不必要的,因为你确实有那个条件WHERE

count由于括号,您可能有错误:

SELECT COUNT(*) AS `numrows`
FROM (`customers`)
LEFT JOIN `parent_companies` AS j2ee39a6a ON `j2ee39a6a`.`id` =     `customers`.`parent_company_id`
WHERE `customers`.`is_approved` =  0
AND  (`organization`  LIKE '%Pizza%' **start_bracket_here**
OR  `title`  LIKE '%Pizza%'
OR  `picture`  LIKE '%Pizza%') ** close bracket here**
HAVING `customers`.`is_approved` = 0;  ** HAVING UNNECESARRY**
于 2013-09-10T08:30:41.363 回答