0

I'm trying to get a PHP-script to show all duplicate values in a MySQL-table. Using the following code I get the wanted results in the phpMyAdmin SQL-query window but it won't work as a PHP mysql_query().

SELECT nordby_log.artikel, a.the_count
FROM
  nordby_log, 
  (SELECT artikel, COUNT(*) AS the_count
  FROM nordby_log
  GROUP BY artikel) AS a
WHERE nordby_log.artikel = a.artikel

Any help is greatly appreciated.

4

1 回答 1

1

您需要使用,在结果分组HAVING进行评估:

SELECT   artikel
FROM     nordby_log
GROUP BY artikel
HAVING   COUNT(*) > 1
于 2012-08-29T10:07:21.547 回答