sql实现逗号分割字段做关联
表:
关联表:
实现的结果:
select
ta.LIMIT_ID,
ta.USER_ID,
ta.OPERATION_ORG_ID,
ta.LAST_CHG_USER,
ta.LAST_CHG_DT,
(SELECT listagg(L.ROLE_NAME,‘,’) within group(order by L.ROLE_NAME)
FROM admin_sm_role L
WHERE INSTR(ta.LIMIT_ROLES, ROLE_ID) > 0
)AS LIMIT_ROLES,
tu.USER_NAME
from admin_sm_user_role_limit ta
left join admin_sm_user tu on ta.user_id = tu.user_id