思路:
在表中6,7号数据,他们的除了ID不同,其他的数据相同;首先,在表中找到一个组合主键,然后以主键group by 然后计算出大于1的记录,然后在通过组合主键找到这条记录,然后就能把记录找到了。就找了两条相同的记录,
select * from tb_stu as t join (select count(*) as amount, t5.stuId, t5.stuName from (select * from tb_stu as s) as t5 group by stuId , t5.stuName) as t5 ON t.stuId = t5.stuId and t.stuName = t5.stuName where t5.amount > 1
时间: 2024-11-08 19:09:40