萬盛學電腦網

 萬盛學電腦網 >> 數據庫 >> mysql教程 >> 刪除重復記錄的sql語句

刪除重復記錄的sql語句

   刪除重復記錄的sql語句

  我們提供了兩款刪除重復記錄的sql語句,一種是用id not in來實例,也算是聯合查詢的方法吧,第二種是臨時表來刪除重復記錄。

  1),delete from tablename where id not in (select max(id) from tablename group by col1,col2,...)

  2),select distinct * into temp from tablename

  delete from tablename

  insert into tablename select * from temp

copyright © 萬盛學電腦網 all rights reserved