1DELETE t1 FROM subscriptions t1
2INNER JOIN subscriptions t2
3WHERE
4 t1.id < t2.id AND
5 t1.user_id = t2.user_id AND t1.name = t2.name
1DELETE FROM table_name WHERE id
2 NOT IN ( SELECT id FROM table_name
3 GROUP BY field_1, field_2)
1DELETE c1 FROM contacts c1
2INNER JOIN contacts c2
3WHERE
4 c1.id > c2.id AND
5 c1.email = c2.email;
1DELETE FROM CONTACTS
2WHERE ID NOT IN
3 (SELECT *
4 FROM (SELECT max(ID)
5 FROM CONTACTS
6 GROUP BY EMAIL) t);
7 -- ⇓ Test it ⇓ (Fiddle source link)
1SELECT
2 col1, COUNT(col1),
3 col2, COUNT(col2)
4FROM
5 table_name
6GROUP BY
7 col1,
8 col2
9HAVING
10 (COUNT(col1) > 1) AND
11 (COUNT(col2) > 1);
12
1DELETE t1 FROM contacts t1
2INNER JOIN contacts t2
3WHERE
4 t1.id < t2.id AND
5 t1.email = t2.email;Code language: SQL (Structured Query Language) (sql)