sorry, I realize my title is confusing. Please let me explain.
I have a database that looks like this:
| i | a | b |
| 1 | 5 | 8 |
| 2 | 3 | 3 |
| 3 | 3 | 6 |
| 4 | 5 | 8 |
| 5 | 1 | 1 |
| 6 | 3 | 3 |
Where i is the ID and a and b are two other fields. As you can see above, ID 2 and ID 6 both have a = 3 and b = 3. The same is true of ID 1 and ID 4, both having 5 for a and 8 for b. Even though the ID number is different, I still consider these rows to be duplicates and would like for all but one to be deleted. It doesn’t matter which one, and the ID numbers to not have to change to compensate for the gaps (but I’m not opposed to that).
I would be happy with a query that gets the above example to something like this:
| i | a | b | | i | a | b |
| 3 | 3 | 6 | | 1 | 5 | 8 |
| 4 | 5 | 8 | or | 2 | 3 | 3 |
| 5 | 1 | 1 | | 3 | 3 | 6 |
| 6 | 3 | 3 | | 5 | 1 | 1 |
Don’t hesitate to ask for more details and thanks in advance!
MySQL can’t delete from a table that it is selecting from. That is why I made a subquery of the select with
select * from () x