如何查表里的重復(fù)項(xiàng) 如何查找數(shù)據(jù)庫(kù)中的重復(fù)數(shù)據(jù)?
如何查找數(shù)據(jù)庫(kù)中的重復(fù)數(shù)據(jù)?下面以 sqlserver數(shù)據(jù)庫(kù)為例進(jìn)行說(shuō)明。 select * from TableA where b in (select b from TableA group by
如何查找數(shù)據(jù)庫(kù)中的重復(fù)數(shù)據(jù)?
下面以 sqlserver數(shù)據(jù)庫(kù)為例進(jìn)行說(shuō)明。 select * from TableA where b in (select b from TableA group by b having count(b) > 1) 這樣就列舉出了b字段所有的重復(fù)數(shù)據(jù),可以根據(jù)對(duì)應(yīng)的行號(hào),取得位于第幾行。 如果要查詢(xún)a字段或者c字段重復(fù)數(shù)據(jù),可以相應(yīng)的把上面的b字段替換成a字段或c字段即可。 舉例: 1、創(chuàng)建表student 2、查詢(xún)語(yǔ)句: select * from student where name in (select name from student group by name having count(name ) > 1) 這樣就查出名字重復(fù)列,以及行號(hào)id。
數(shù)據(jù)庫(kù)中查找名字相同的人?
如果每個(gè)學(xué)生只有一條記錄的話(huà),按姓名分組,統(tǒng)計(jì)記錄條數(shù)(大于1),再這些有相同姓名條數(shù)的人的姓名作為條件,檢索出相應(yīng)信息 語(yǔ)句如下: select* from學(xué)生表 where姓名in (selecct姓名 from學(xué)生表 groupby姓名 havingcount(*)>1)