1 GROUP BY 和HAVING组合查询出所有重复记录
SELECT * FROM brand WHERE name IN (SELECT name FROM brand GROUP BY `name` HAVING COUNT(`name`)>1 );
2 mysql不支持对同一张表查询的同时进行删除或更改的操作,所以直接将SELECT改为DELETE会报错:
DELETE * FROM brand WHERE name IN (SELECT name FROM brand GROUP BY `name` HAVING COUNT(`name`)>1 ) AND created_date ="2019-05-22";
3 查询name的语句设置别为一个临时表,并根据时间删除重复和数据
DELETE FROM brand WHERE name IN (SELECT t.name FROM (SELECT name FROM brand GROUP BY `name` HAVING COUNT(`name`)>1 ) t )AND created_date ="2019-05-22";