用SQL查找重复项? - Wring SQL声明?

时间:2017-02-24 15:33:50

标签: mysql sql

我想看到我有重复条目的所有行。但我没有看到我的失败。有谁知道我怎么能解决这个问题? - SQL说:Unknown field cnt in where clause

我也尝试了= 0,甚至没有计数器和where条件但是它正在运行。只有在没有where条件的情况下,我也会在表格中看到cnt但是。错误在哪里?

SELECT `name`, `price`, `shop`, `url`, `publisher`, `platform`, `category` Count(*) as cnt 
FROM `wp_all_import_xml`
WHERE cnt > 1
GROUP BY `name`, `price`, `shop`, `url`, `publisher`, `platform`, `category`

图片:enter image description here

问候,谢谢!

3 个答案:

答案 0 :(得分:1)

改为使用HAVING

SELECT `name`, `price`, `shop`, `url`, `publisher`, `platform`, `category` Count(*) as cnt 
FROM `wp_all_import_xml`
GROUP BY `name`, `price`, `shop`, `url`, `publisher`, `platform`, `category`
HAVING Count(*) > 1

答案 1 :(得分:1)

你应该使用有条款

SELECT `name`, `price`, `shop`, `url`, `publisher`, `platform`, `category` Count(*) as cnt 
FROM `wp_all_import_xml`
GROUP BY `name`, `price`, `shop`, `url`, `publisher`, `platform`, `category`
having cnt > 1

答案 2 :(得分:1)

使用WHERE

对具有HAVING行的filtere过滤组
SELECT `name`, `price`, `shop`, `url`, `publisher`, `platform`, `category`, Count(*) as cnt 
FROM `wp_all_import_xml`
GROUP BY `name`, `price`, `shop`, `url`, `publisher`, `platform`, `category`
HAVING cnt>1