刪除表中多余的重復記錄,重復記錄是根據單個字段(id)來判斷,只留有rowid最小的記錄
//刪除用戶 根據用戶名,并且不包括最小ID delete from users where username in ( --根據用戶名稱排序,大于1 select username from users group by username having count(username) > 1 ) and Id not in ( --根據用戶名排序,獲取最小ID select min(Id) from users group by username having count(username) > 1 );
轉載請注明出處 AE博客|墨淵 ? SQL 刪除重復記錄,只保留一條記錄
發表評論