I have table containing following entries
Id | Accno | Name | Hash
----+----------+-----------+---------
1 | 11 | ABC | 01110
2 | 11 | ABC |
3 | 22 | PQT |
4 | 33 | XYZ | 03330
5 | 44 | LMN | 04440
6 | 33 | XYZ |
I need SQL query to remove duplicate entry from table and keep atleast single entry in table whose hash value is present. and for those entries which are not duplicate should also remain in table.
Accno,Name, or both together?SELECTquery that returns all the rows you want to keep. Then useDELETE FROM YourTable WHERE id NOT IN (SELECT id FROM (<subquery>)), where<subquery>is the query you wrote.