Answer the question
In order to leave comments, you need to log in
Removing Duplicate SQL Rows
I want to remove duplicate lines.
Only the id field (autoincrement) differs.
I tried to make several different "NOT IN" and "NOT EXIST" constructs, but they all give a syntax error. Apparently I'm a shitty requester. What queries do you use to remove duplicates?
Answer the question
In order to leave comments, you need to log in
DELETE `t1`.* FROM `table` AS `t1`
LEFT JOIN (SELECT `id` FROM `table` GROUP BY `field1`, `field2`, ...) AS `t2`
ON `t1`.`id` = `t2`.`id`
WHERE `t2`.`id` IS NULL
DELETE FROM tbl WHERE id NOT IN(
SELECT MAX(id) FROM tbl GROUP BY <поле 1>[,<поле 2>]
)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question