I have a table but it has no unique ID or primary key.
It has 3 columns in total.
| name | user_id | role_id |
|---|---|---|
| ben | 1 | 2 |
| ben | 1 | 2 |
| sam | 1 | 3 |
I'd like to remove one entry with the name Ben.
So output would look like this
| name | user_id | role_id |
|---|---|---|
| ben | 1 | 2 |
| sam | 1 | 3 |
Most of the examples shows deleting duplicate entries with ID or primary key. However how would I retain one entry whilest removing the other ones?
Using the following query I was able to get duplicated rows
SELECT name, user_id, role_id, count(*) FROM some_table
GROUP BY name, user_id, role_id
HAVING count(*) > 1
To clarify, I am looking to delete these rows.
Prefer not creating a new table.