sql查詢字段重復(fù)的記錄 sql查找多字段相同記錄?
sql查找多字段相同記錄?兩種方法,一種是查詢重復(fù)的數(shù)據(jù),只查詢重復(fù)記錄,不管其余信息,如ID什么的: select uid, time from ztest GROUP BY uid, time
sql查找多字段相同記錄?
兩種方法,一種是查詢重復(fù)的數(shù)據(jù),只查詢重復(fù)記錄,不管其余信息,如ID什么的: select uid, time from ztest GROUP BY uid, time having count(*)>1 查出結(jié)果是 uid time 1 1 還有一種是查詢你指定信息,可以查詢出ID信息: select distinct a.id, a.uid, a.time from ztest a join ztest b on a.id != b.id where a.uid = b.uid and a.time = b.time 查詢結(jié)果是: id uid time 1 1 1 3 1 1