首页 > 数据库 > SQL Server > 正文

查询表里有N组相同记录的SQL语句

2024-08-31 00:47:04
字体:
来源:转载
供稿:网友

表里面有N条相同的记录,要查出来.

如:

ID Name

12 d

34 e

543 t

34 e

12 d

45 y

543 t

查询的结果应为:

ID Name

12 d

12 d

34 e

34 e

543 t

543 t

假如表名为Table03,可以用下面语句轻松实现:

select id,name from table03 where name in(select name from table03 group by name having count(name)>1)

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表