Skip to content
Advertisement

How to query for delete the same data out of the table?

I want the output to look like this.

I want to delete it for the output to look like this. In one group there should be only 1 user_id.

I get all user_id, group_id and count more than 1 but I don’t know how to delete duplicates and leave only 1 left.

Ps. My English is probably not perfect, pls excuse any mistakes

Advertisement

Answer

Make a subquery to get a list of minimum ids for any combination of users and groups. Then remove everything else.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement