sql查询字段重复的记录 sql查找多字段相同记录?

sql查找多字段相同记录?两种方法,一种是查询重复的数据,只查询重复记录,不管其余信息,如ID什么的: select uid, time from ztest GROUP BY uid, time

sql查找多字段相同记录?

两种方法,一种是查询重复的数据,只查询重复记录,不管其余信息,如ID什么的: select uid, time from ztest GROUP BY uid, time having count(*)>1 查出结果是 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 查询结果是: id uid time 1 1 1 3 1 1