For example: table name: players
sno | name | coach_id |
---|---|---|
1 | Sachin | 1 |
2 | Sachin | 5 |
3 | Kohli | 1 |
4 | Ganguly | 2 |
5 | Kohli | 4 |
6 | Gambir | 3 |
Query:
DELETE FROM players USING players , players AS virtualtable
WHERE players .sno > virtualtable.sno
AND players .name = virtualtable.name
Output:
sno | name | coach_id |
---|---|---|
1 | Sachin | 1 |
3 | Kohli | 1 |
4 | Ganguly | 2 |
6 | Gambir | 3 |
No comments:
Post a Comment