Hello SQL query experts! I have one table called 'mytable' which has 2 columns such as id and title . I tried to remove duplicates except only one record(row) comparing title. Below was my choice:
DELETE FROM `myTable` AS `m1`
WHERE `m1`.`id`
NOT IN (SELECT MIN(`b`.`id`) as `recordid` FROM `myTable` AS `b` GROUP BY `b`.`title`)
error : Error in query (1064): Syntax error near '* FROM `myTable` AS `m1` WHERE `m1`.`id` NOT IN (SELECT MIN(`b`.`id`) as `reco' at line 1
but I faced a trouble and tried to resolve this problem more than 2 hours.
It seems like very simple problem.
But I can't figure it out. So I am asking to stackoverflow!
And mainly, I see something strange. I tried like this but it has no any error.
SELECT * FROM `myTable` AS `m1`
WHERE `m1`.`id`
NOT IN (SELECT MIN(`b`.`id`) as `recordid` FROM `myTable` AS `b` GROUP BY `b`.`title`)
When I run this query, I can obtain the list of records(rows) I want to delete from 'myTable' table.
Why do I face a deletion problem although I can obtain the list to delete?
I need your help really. Thanks everyone!