SQL 查询一个表中 两个字段数量都大于2条记录的数据
例:A表sns_ids_name字段31101101aaa2101101bbb3102102ccc4102112ddd5103103eee得到结果sns_ids_name...
例:
A表
sn s_id s_name 字段3
1 101 101 aaa
2 101 101 bbb
3 102 102 ccc
4 102 112 ddd
5 103 103 eee
得到结果
sn s_id s_name 字段3
1 101 101 aaa
2 101 101 bbb
求高手解答,在线等。。。。。 展开
A表
sn s_id s_name 字段3
1 101 101 aaa
2 101 101 bbb
3 102 102 ccc
4 102 112 ddd
5 103 103 eee
得到结果
sn s_id s_name 字段3
1 101 101 aaa
2 101 101 bbb
求高手解答,在线等。。。。。 展开
2个回答
展开全部
SELECT *
FROM A表 W
WHERE EXISTS(SELECT s_id,s_name FROM A表 WHERE sid=W.sid and s_name=W.s_name group by s_id,s_name having count(*)>=2)
FROM A表 W
WHERE EXISTS(SELECT s_id,s_name FROM A表 WHERE sid=W.sid and s_name=W.s_name group by s_id,s_name having count(*)>=2)
追问
出来了 刚写错了,谢谢
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
引用古舟蓑笠翁的回答:
SELECT *
FROM A表 W
WHERE EXISTS(SELECT s_id,s_name FROM A表 WHERE sid=W.sid and s_name=W.s_name group by s_id,s_name having count(*)>=2)
SELECT *
FROM A表 W
WHERE EXISTS(SELECT s_id,s_name FROM A表 WHERE sid=W.sid and s_name=W.s_name group by s_id,s_name having count(*)>=2)
展开全部
SELECT *
FROM A表 W
WHERE EXISTS(SELECT s_id,s_name FROM A表 group by s_id,s_name having count(*)>=2)
FROM A表 W
WHERE EXISTS(SELECT s_id,s_name FROM A表 group by s_id,s_name having count(*)>=2)
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询