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)免費學(xué)習(xí)推薦:mysql視頻教程