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)
1DELETE FROM FriendsData WHERE fID
2 NOT IN ( SELECT fID FROM FriendsData
3 GROUP BY UserID, FriendsUserID, IsSpecial, CreatedBy)
4
1DELETE FROM table_name
2WHERE
3 id IN (
4 SELECT
5 id
6 FROM (
7 SELECT
8 id,
9 ROW_NUMBER() OVER (
10 PARTITION BY field_1
11 ORDER BY field_1) AS row_num
12 FROM
13 table_name
14
15 ) t
16 WHERE row_num > 1
17);