请大家帮忙看下这两个语句怎么连接起来
第一个
select
a.gznr 工作内容
,a.jhwcrq 计划完成日期,a.requestid 流程id
,a.wasj 完成时间,a.bez 备注
,d.lastname 配合人
from formtable_main_50 a
left join hrmresource d
on a.peiher=d.id
第二个:
select
lastname,id
from hrmresource where id in (
SELECT REGEXP_SUBSTR(peiher, '[^,]+', 1,rownum) from
(select peiher from formtable_main_50 )
CONNECT BY ROWNUM <=
LENGTH (peiher) - LENGTH (REPLACE ( peiher, ',','')) +1)
把这两条语句写成一条,主要想要查询数据库里面d.lastname 配合人这个多人力资源字段,好像第二个语句还有点小问题,菜鸟实在不会改 ,请大侠指教
[解决办法]
SELECT LASTNAME, ID
FROM HRMRESOURCE
WHERE ID IN
(SELECT REGEXP_SUBSTR(PEIHER, '[^,]+', 1, LEVEL)
FROM (SELECT PEIHER FROM FORMTABLE_MAIN_50)
CONNECT BY LEVEL <=
LENGTH(PEIHER) - LENGTH(REPLACE(PEIHER, ',', '')) + 1)
select a.gznr 工作内容,
a.jhwcrq 计划完成日期,
a.requestid 流程id,
a.wasj 完成时间,
a.bez 备注,
d.lastname 配合人
from formtable_main_50 a
left join (select lastname, id
from hrmresource
where id in
(SELECT REGEXP_SUBSTR(peiher, '[^,]+', 1, rownum)
from (select peiher from formtable_main_50)
CONNECT BY ROWNUM <=
LENGTH(peiher) -
LENGTH(REPLACE(peiher, ',', '')) + 1)) d
on a.peiher = d.id;