mysql刪除重復數據
阿新 • • 發佈:2018-10-08
刪除重復數據 sel code mysql delete div rom 重復數 max
DELETE FROM table WHERE id IN ( SELECT src.id FROM ( SELECT t1.id FROM table t1 WHERE ( t1.col1, t1.col2, t1.col3, t1.col4, t1.col5 )IN ( SELECT col1, col2, col3, col4, col5 FROM table GROUPBY col1, col2, col3, col4, col5 HAVING count(*) > 1 ) AND t1.id NOTIN ( SELECT MAX(id) FROM table GROUP BY col1, col2, col3, col4, col5 HAVING count(*) > 1 ) ) src );
mysql刪除重復數據