Delete duplicate data in mysql database

The sentence used at the beginning shows an error

delete from con where id in(select min(id) id1 from con group by url having count(url)> 1)
(con is the table name, id and url are the field names in the table)

Query data while deleting data, and delete while querying data. MySQL does not support the operation of updating and querying the same table.

The correct sql is as follows:

1. Query the duplicate data first

2. Use the repeated data as the third table

3. Go delete again

delete from con where id in(select conn.id1 from(select min(id) id1 from con group by url having count(url) > 1) conn )

Guess you like

Origin blog.csdn.net/qq_45619283/article/details/114240637