共計 691 個字符,預(yù)計需要花費 2 分鐘才能閱讀完成。
自動寫代碼機器人,免費開通
這篇文章給大家分享的是有關(guān) sql 怎么篩選出重復(fù)數(shù)據(jù)的內(nèi)容。丸趣 TV 小編覺得挺實用的,因此分享給大家做個參考,一起跟隨丸趣 TV 小編過來看看吧。
sql 篩選出重復(fù)數(shù)據(jù)的方法:使用“select * from 表名 where 條件”語句來篩選重復(fù)數(shù)據(jù);可以使用一個或者多個表,表之間使用逗號(,)分割,并使用 WHERE 語句來設(shè)定查詢條件。
本教程操作環(huán)境:windows7 系統(tǒng)、mysql8 版本、Dell G3 電腦。
在電腦上打開數(shù)據(jù)庫,這里新建一張含有重復(fù)數(shù)據(jù)的 user 表做示例。
查詢出了數(shù)據(jù)庫中 user 表的重復(fù)數(shù)據(jù)。
select * from user where name in (select name from user group by name having count(name) 1)
刪除姓名重復(fù)的數(shù)據(jù)
delete from user where name in (select name from user group by name having count(name) 1)
去掉重復(fù)數(shù)據(jù),這里去掉了張三的重復(fù)數(shù)據(jù)
select distinct name from user
去掉班級相同的重復(fù)數(shù)據(jù)
select distinct class from user
去掉兩個字段的重復(fù)數(shù)據(jù)
select distinct name,class from user
感謝各位的閱讀!關(guān)于“sql 怎么篩選出重復(fù)數(shù)據(jù)”這篇文章就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,讓大家可以學(xué)到更多知識,如果覺得文章不錯,可以把它分享出去讓更多的人看到吧!
向 AI 問一下細(xì)節(jié)