Tracking Down Duplicates
mysql> CREATE TABLE authors (
-> authID int(11) NOT NULL auto_increment PRIMARY KEY ,
-> authName varchar(60),
-> ts timestamp
-> );
Query OK, 0 rows affected (0.01 sec)
mysql>
mysql>
mysql>
mysql>
mysql> INSERT INTO authors VALUES (1,'Tom','2004-12-02 18:36:51'),
-> (2,'Jack','2004-12-02 18:36:51'),
-> (3,'Jane','2004-12-02 18:36:51'),
-> (4,'Amy','2004-12-02 18:36:51'),
-> (5,'Bob','2004-12-02 18:36:51'),
-> (6,'Race','2004-12-02 18:36:51'),
-> (7,'Green','2004-12-02 18:36:51');
Query OK, 7 rows affected (0.00 sec)
Records: 7 Duplicates: 0 Warnings: 0
mysql>
mysql>
mysql> SELECT authName, COUNT(*) AS cnt
-> FROM authors
-> GROUP BY authName
-> HAVING cnt>1;
Empty set (0.00 sec)
mysql>
mysql> drop table authors;
Query OK, 0 rows affected (0.00 sec)
mysql>
mysql>
Related examples in the same category