I want to drop all rows in a table of mySQL that have a duplicate using GROUP BY
. My table has fields name date position email and looks like
+----------+---------------+----------+--------------------+
| M | 1976-10-03 | 1 | m@gmail |
| R | 1982-03-26 | 2 | r@gmail.com |
| C | 1987-09-03 | 3 | c@gmail.com |
| M | 1976-10-03 | 1 | m@gmail |
+----------+---------------+----------+--------------------+
I want to get
+----------+---------------+----------+--------------------+ |
| R | 1982-03-26 | 2 | r@gmail.com |
| C | 1987-09-03 | 3 | c@gmail.com |
+----------+---------------+----------+--------------------+
My attempt (from the answers to similar questions)
DELETE FROM ts1 WHERE * IN (SELECT * FROM ts1 GROUP BY * HAVING COUNT(*)>1);
Where are the errors? I understand I'm using too many * but I want to avoid naming all columns because they are too many in my actual table. Notice that I want to check for duplicates over the entire row.