表是
id group_id name
1 A q
2 B q
3 C e
4 A r
5 B tgroup_id是人所在的组
如何查询同时在A组B组的人名(name)?
id group_id name
1 A q
2 B q
3 C e
4 A r
5 B tgroup_id是人所在的组
如何查询同时在A组B组的人名(name)?
解决方案 »
- 请问过程中表的别名可否重复使用
- Oracle occi createConnection连接失败
- 关于配置两个监听的问题
- 问一个sum(decode()) 问题 请帮忙,谢谢了
- 用户建立的表默认初始大小如何改
- 管理员/口令/manager sever与配置辅助工具-编辑配置参数中的用户名/口令/服务一样吗?
- oracle 远程连接慢的问题!高分送!!!
- 请问在sql server中如何在select的结果中添加行号如1,2,3。。。多谢!
- win8.1系统把电脑之前安装的Oracle12C卸载,重新安装Oracle11g,报错:组件安装失败,在注册表中没有找到指定的主目录名
- 【数据库选择】数据库的利弊还有数据库类型的定义
- ◆oracle解锁问题◆
- update
FROM (SELECT NAME, wmsys.wm_concat(group_id) AS gr
FROM a
GROUP BY NAME)
WHERE gr IN ('A,B', 'B,A')这样应该可以,不过貌似数据库要10g以上
如有有个人同时在ABC组怎么办
select name from table a,table b where a.name=b.name and a.groupid=a and b.groupid=b;
select count(name) con,name from (
select distinct name from table where group_id= 'B'
union
select distinct name from table where group_id = 'A')
where group by name)
where con = 2
FROM a t1
WHERE EXISTS (SELECT 1
FROM a t2
WHERE t1.NAME = t2.NAME
AND t2.group_id = 'A')
AND EXISTS (SELECT 1
FROM a t2
WHERE t1.NAME = t2.NAME
AND t2.group_id = 'B')
真细心啊SELECT NAME
FROM (SELECT NAME, wmsys.wm_concat(group_id) AS gr
FROM a
GROUP BY NAME)
WHERE gr LIKE '%A,B%'
OR gr LIKE '%B,A%'
intersect
select name from yourtable where group_id='B';