select b.d_c_name,a.t_id from
(
select a.t_id,nvl2(a.t_visitcitys,a.t_visitcitys,'2') as
citys from ysu_fams_tasks a
where nvl2(a.t_visitcitys,a.t_visitcitys,'2') !='2'
) a left join
(select * from ysu_sys_childdict c where c.d_c_pid = 37) b
on ','||a.citys||',' like '%,'||b.d_c_name||',%'
其中 ysu_fams_tasks 列t_visitcitys 的数据是
978 新加坡,东京
985 东京,伦敦,哥本哈根
94 台湾
1166 利雅得
1167 多哈,哥本哈根
96 台湾
1113 柏林
87 新加坡,香港
1135 东京
1136 柏林
1138 东京
dict 表的数据是
1113 柏林
87 新加坡
1135 东京
1136 柏林
1138 东京
关联后的数据是
东京 978
新加坡 978
东京 978
哥本哈根 985
伦敦 985
东京 985
东京 985
伦敦 985
台湾 94
利雅得 1166
哥本哈根 1167
将 列中多条的数据取出来显示