W
W
Wolframius2017-05-23 12:04:52
SQL
Wolframius, 2017-05-23 12:04:52

How to remove duplicate records in a table?

There is a table. There are duplicate entries. How can I remove them? I've been going crazy all day.
I do so

delete from `admin_eda`.`eda` 
where `eda`.`id` not in (
                         select min(`eda`.`id`) 
                         from `admin_eda`.`eda` 
                         group by `eda`.`name`
                        )

Throws
#1093 - Table 'eda' is not allowed to be specified in the FROM table list to make changes to it

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
V Sh., 2017-05-23
@JuniorNoobie

Everything has already been done. You just need to find .

R
Rsa97, 2017-05-23
@Rsa97

DELETE `t1`.*
  FROM `admin_eda`.`eda` AS `t1`
  LEFT JOIN `admin_eda`.`eda` AS `t2` ON `t2`.`name` = `t1`.`name` AND `t2`.`id` < `t1`.`id`
  WHERE `t2`.`id` IS NULL

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question