select wm_concat(ur.lname) from tpl_user_t ur where ur.w3_account in (
(select '''' || replace(st.person,',',''',''') ||'''' s from eso_review_standardaccount st
where st.deviceid='2273') 中间这段sql 输出是 -- 'l45254','c00152559' 查询结果为空 )select wm_concat(ur.lname) from tpl_user_t ur where ur.w3_account in (
'l45254','c00152559' --这样查询是有值的好郁闷啊。。这是什么情况?
)
实在是找不到解决方案,请大家帮忙看下,谢谢
(
FNAME VARCHAR2(200), --lXX 223344
LNAME VARCHAR2(200),
w3_account VARCHAR2(200) --l223344
)eso_review_standardaccount 这个表的 person 字段数据就是 l223344,l54530 多值 ,号分割用 eso_review_standardaccount 和 TPL_USER_T查询 person 字段和w3_account 关联
'l45254','c00152559'
)你这样查询,IN里面相当于2个选项,而你第一种方法, 'l45254','c00152559'作为一个字符串返回,相当于一个选项,当然查不到了,相当于这样的一个变量"'l45254','c00152559'"
虽然你想拼成'AAA','BBB'的形式,但毕竟是用sql返回的,所以实际执行的时候是作为一个值。两种方法解决
一,in后面的sql先取得数据,然后传给外面的sql
二,还是用sql,
可以用like查询
select wm_concat(ur.lname) from tpl_user_t ur,
(select st.person s from eso_review_standardaccount st
where st.deviceid='2273') t
where ur.w3_account like t.s || ',%
'or ur.w3_account like '%,' || t.s
(select st.person s from eso_review_standardaccount st
where st.deviceid='2273') t
where ur.w3_account like t.s || ',%'
or ur.w3_account like '%,' || t.s
select * from(select regexp_substr(st.person||',','[^,]+',1,rownum) s
from eso_review_standardaccount st
connect by rownum<=length(regexp_replace(st.person||',','[^,]+'))))
试试,我自己测试通过了
不知道你的 st.person 这个字段的值是什么样的?
亲,如果针对条件查询 这个是正确的。。可是我这是表之间的关联 如果把那个where条件去掉,。就没有达到效果。。
因为是很多行关联起来的
(select wm_concat(person) person_sum from eso_review_standardaccount)
select wm_concat(ur.lname) from tpl_user_t ur where ur.w3_account in (
select * from(select regexp_substr(person_sum||',','[^,]+',1,rownum) s from table_linshi
connect by rownum<=length(regexp_replace(person_sum||',','[^,]+')))
)