1 First create a table for demonstration. Create the table first as shown in the figure
2 Then switch to the command line to view the table content in the database, there are indeed duplicate items.
3 First query out the duplicate rows
4 Now what you want to delete is the data that appears in this table, and only keep the row with the largest id in each group, so you need to use the max function to query the largest row, so first find out that these ids are not in the largest row or query the
id The maximum value in these
and then will not be in these non-repeated ones, these can be deleted
delete from deleteDuplicate where id not in (select t.maxId from (select max(id) as maxId from deleteDuplicate group by name,age,country) t);