表A有字段Column1,字段值是字符串:'A,B', 'A','B','B,C','C'
表B有字段Column12 字段值是字符串:'B','A','B','C'
怎么写sql查询表B字段Column12等于表A字段Column1的记录,即:表A字段Column1解析成单个字符如A,b
表B有字段Column12 字段值是字符串:'B','A','B','C'
怎么写sql查询表B字段Column12等于表A字段Column1的记录,即:表A字段Column1解析成单个字符如A,b
select column12 from b
where exists(select 1 from a where a.column1=b.column12)
表A字段Column1解析成单个字符如A,b是什么意思
要把'A,B'分成'A'和'B'?
为什么
union
select substr(column1,1,1) from a where length(column)=3
union
select substr(column1,3,1) from a where length(column)=3
union
select substr(column1,1,1) from a where length(column)=3
union
select substr(column1,3,1) from a where length(column)=3
如果column1长度不定呢?
substr(a.a,instr(a.a,',',1,b.num+1)+1,instr(a.a,',',1,b.num+2)-instr(a.a,',',1,b.num+1)-1) a
from(
select ','||a||',' a,length(a)-length(replace(a,',',''))num from test_j)a
left join
(select rownum-1 num from dual connect by rownum<20)b
on a.num>=b.numA A
,B,C, C
,B,C, B
,A,B, B
,A,B, A
,C, C
,A, A
,B, B
(select 1 from t1 where instr( ','||t2.b||',', ','||t1.a||',' ) > 0 )
这样可以达到你的要求吗?
from equ_sys_info_detail
where info_type_code = '420'
and (V_MAT_CODE LIKE info_detail_code||'%' )
and INFO_DETAIL_STATE = 'N'
and exists ( select 1 from v_message_unit_emp
where unit_type = '3' and
emp_code = f_get_cur_user_id() and
(info_detail_desc like '%'||unit_code||'%')
);
参考。结贴。谢谢。