oracle数据库一个表字段中存了id,并以逗号分隔,id对应的详细信息在另一个表中
0
现在有两个表,表a中
aid 主管领导
1 1,2,3
2 2,4
表b中
bid 姓名
1 李一
2 刘二
3 张三
4 李四
怎么联合查询出
序号 主管领导 主管领导姓名
1 1,2,3 李一,刘二,张三
2 2,4 刘二,李四
求救!!!!
aid 主管领导
1 1,2,3
2 2,4
表b中
bid 姓名
1 李一
2 刘二
3 张三
4 李四
怎么联合查询出
序号 主管领导 主管领导姓名
1 1,2,3 李一,刘二,张三
2 2,4 刘二,李四
求救!!!!
没有找到相关结果
重要提示:提问者不能发表回复,可以通过评论与回答者沟通,沟通后可以通过编辑功能完善问题描述,以便后续其他人能够更容易理解问题.
1 个回复
老头子 - 专注是唯一的捷径 2015-11-06 回答
赞同来自: 梁勇
with laotouzi as (
select leader, regexp_substr(leader, '[^,]+', 1, level) value,aid
from a
connect by leader = prior leader
and instr(leader || ',', ',', 1, level) > 0
and prior dbms_random.value is not null
)
select aid,wm_concat(name)
from laotouzi aa,b
where aa.value = b.bid
group by aid