Oracle列转行
数据格式为
ID FID
1 1,2,3
2 2,3,4
需要转换为
ID FID
1 1
1 2
1 3
2 2
2 3
2 4
[@more@]select p.dict_id,p.name_key from base_dict_info p,(
select o.dict_id,wm_concat(o.name_key) keys from base_dict_info o group by o.dict_id ) tt
where tt.dict_id = p.dict_id and regexp_instr(tt.keys,'(^|,)('||p.name_key||'){1}($|,)')>0
--测试instr正则表达式
select regexp_instr('132,123,234','(^|,)(1232){1}($|,)') from dual
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/25261409/viewspace-1058798/ ,如需转载,请注明出处,否则将追究法律责任。