求一个SQL语句

php_aga 2011-11-08 08:45:53
table name :TEST
ID NUM
1 3
1 4
2 5
3 6
7 9
3 8

请问如何一个语句查询出同一ID有1个以上的NUM值
...全文
68 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
GIS_Cloud 2011-11-10
  • 打赏
  • 举报
回复
跟前面那个基本一样,楼上正解
QQHRSWB 2011-11-09
  • 打赏
  • 举报
回复
select *
from test
where id in (select id from TEST group by id having count(*)>1)
正解
Gary-chen 2011-11-08
  • 打赏
  • 举报
回复
select id from test group by by having count(num)>1
zalvsa 2011-11-08
  • 打赏
  • 举报
回复
select id,count(distinct num) from test group by id
ACMAIN_CHM 2011-11-08
  • 打赏
  • 举报
回复
select *
from test
where id in (select id from TEST group by id having count(*)>1)
rucypli 2011-11-08
  • 打赏
  • 举报
回复
select id from test group by id having count(distinct num)>1

56,682

社区成员

发帖
与我相关
我的任务
社区描述
MySQL相关内容讨论专区
社区管理员
  • MySQL
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧