一些有用的sql

1、查询重复数据

SELECT a.id FROM (Select Max(area_id) as id  From u_area b where b.area_parentid = '1816' Group By area_name HAVING COUNT(1) > 1

2、删除重复数据

Delete FROM u_area  Where area_id In (SELECT a.id FROM (Select Max(area_id) as id  From u_area b where b.area_parentid = '1816' Group By area_name HAVING COUNT(1) > 1)a)

 

你可能感兴趣的:(php)