首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > oracle >

关于ORACLE SPLIT 查询的有关问题,望解答

2012-09-12 
关于ORACLE SPLIT 查询的问题,望大虾解答有两个表的关系是这样的。table1:idiid1A,B2B,C,D3A,DTABLE2:IDMCA

关于ORACLE SPLIT 查询的问题,望大虾解答
有两个表的关系是这样的。
table1:
id iid
1 A,B
2 B,C,D
3 A,D

TABLE2:
ID MC
A this is a
B this is B
C this is B


我想通过tbale1的ID做为参数传值,查询TABLE2包含在TBALE1.iid中的所有记录。
现在我已有split函数来拆分IID,请问要实现我上述的需求要怎么写呢? 


[解决办法]

SQL code
with table1(id,iid) as(select 1,'A,B' from dualunion all select 2,'B,C,D' from dualunion all select 3,'A,D' from dual),table2(id,mc) as(select 'A','this is a' from dualunion all select 'B','this is b' from dualunion all select 'C','this is c' from dual)select * from table2where exists(select 1 from table1 where table1.id=1--此处传你的id and instr('%,'||iid||',%',','||table2.id||',')>0);/*I MC                                                                            - ---------                                                                     A this is a                                                                     B this is b  */ 

热点排行
Bad Request.