I want to delete some duplicate rows (ID is duplicate), based on its row number (there is no primary key), so that I can thereafter make the ID column my primary key.
My current query does give back the correct rows I want to delete:
SELECT *
FROM table_name
WHERE @row_number:=@row_number NOT IN (
SELECT * FROM (
SELECT MIN(@row_number:=@row_number)
FROM table_name
GROUP BY id
) x
);
But when I try to delete them using the following query, nothing happens.
DELETE
FROM table_name
WHERE @row_number:=@row_number NOT IN (
SELECT * FROM (
SELECT MIN(@row_number:=@row_number)
FROM table_name
GROUP BY id
) x
);
Any idea what I'm doing wrong here? Help is highly appreciated!