自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

MYSQL查詢重復(fù)記錄的方法

數(shù)據(jù)庫 MySQL
重復(fù)記錄是我們使用MYSQL數(shù)據(jù)庫經(jīng)常會遇到的問題,下文就為您介紹幾種查詢重復(fù)記錄的方法,供您參考學(xué)習(xí)之用。

MYSQL查詢重復(fù)記錄的方法很多,下面就為您介紹幾種最常用的MYSQL查詢重復(fù)記錄的方法,希望對您學(xué)習(xí)MYSQL查詢重復(fù)記錄方面能有所幫助。

1、查找表中多余的重復(fù)記錄,重復(fù)記錄是根據(jù)單個字段(peopleId)來判斷

  1. select * from people   
  2. where peopleId in (select peopleId from people group by peopleId having count(peopleId) > 1)   

2、刪除表中多余的重復(fù)記錄,重復(fù)記錄是根據(jù)單個字段(peopleId)來判斷,只留有rowid最小的記錄

  1. delete from people   
  2. where peopleId in (select peopleId from people group by peopleId   having count(peopleId) > 1)   
  3. and rowid not in (select min(rowid) from people group by peopleId having count(peopleId )>1)   

3、查找表中多余的重復(fù)記錄(多個字段)

  1. select * from vitae a   
  2. where (a.peopleId,a.seq) in (select peopleId,seq from vitae group by peopleId,seq having count(*) > 1)   

4、刪除表中多余的重復(fù)記錄(多個字段),只留有rowid最小的記錄

  1. delete from vitae a   
  2. where (a.peopleId,a.seq) in (select peopleId,seq from vitae group by peopleId,seq having count(*) > 1)   
  3. and rowid not in (select min(rowid) from vitae group by peopleId,seq having count(*)>1)   

5、查找表中多余的重復(fù)記錄(多個字段),不包含rowid最小的記錄

  1. select * from vitae a   
  2. where (a.peopleId,a.seq) in (select peopleId,seq from vitae group by peopleId,seq having count(*) > 1)   
  3. and rowid not in (select min(rowid) from vitae group by peopleId,seq having count(*)>1)   

 

 

 

【編輯推薦】

MySQL隨機(jī)查詢的實現(xiàn)方法

MySQL查詢中間記錄的方法

MySQL查詢結(jié)果按某值排序

使用函數(shù)實現(xiàn)MySQL查詢行號

MySQL查詢中的非空問題

責(zé)任編輯:段燃 來源: 互聯(lián)網(wǎng)
相關(guān)推薦

2010-10-13 17:07:46

MySQL刪除重復(fù)記錄

2010-10-13 17:13:17

MySQL重復(fù)記錄

2010-11-23 14:26:02

MySQL刪除重復(fù)記錄

2010-11-15 14:42:03

Oracle查詢重復(fù)記

2010-10-27 16:49:23

Oracle刪除重復(fù)記

2010-09-03 09:49:39

SQL刪除

2011-05-24 10:04:39

Oracle重復(fù)記錄

2010-09-03 11:42:04

SQL刪除

2011-05-17 11:23:02

Oracle數(shù)據(jù)庫

2010-09-25 16:17:25

SQL語句

2010-10-27 16:56:05

Oracle重復(fù)記錄

2010-09-28 15:46:22

SQL刪除重復(fù)記錄

2010-09-28 15:40:51

SQL刪除重復(fù)記錄

2011-03-04 17:30:42

Oracle數(shù)據(jù)庫

2010-11-25 14:05:15

MySQL查詢中間記錄

2010-07-26 17:00:11

SQL Server查

2010-09-30 10:29:56

DB2刪除重復(fù)記錄

2018-09-11 17:13:23

MySQ數(shù)據(jù)庫重復(fù)記錄

2011-03-21 17:25:08

SQL Server數(shù)重復(fù)記錄

2010-11-25 14:40:27

MySQL查詢
點贊
收藏

51CTO技術(shù)棧公眾號