select * from 要查询的表
where 查重的字段 in ( select 查重的字段 from 要查询的表group by 查重的字段 having count(查重的字段 )>1 )ORDER BY 查重的字段
例句:
从student表中,查询学号相同的学生信息,并且将结果进行升序排序
select * from student
where sid in ( select sid from student group by sid having count(sid )>1 )ORDER BY sid
该博客介绍了如何使用SQL查询语句来查找表中的重复数据,并按指定字段进行升序排序。通过`SELECT * FROM table WHERE field IN (SELECT field FROM table GROUP BY field HAVING COUNT(field) > 1) ORDER BY field`的结构,可以有效地定位和展示学号相同的学生信息。这种方法对于数据清理和分析非常有用。
1166

被折叠的 条评论
为什么被折叠?



