17,089
社区成员
发帖
与我相关
我的任务
分享
SELECT *
FROM TRUST_INFO A, TRUST_ACCOUNT_INFO B, TCMS_ACCOUNT_TRUST_ASSO C
WHERE ((A.SERVICE_MODE = ' 01' AND A.TRUST_NO = B.TRUST_NO) OR
(A.SERVICE_MODE = ' 02' AND A.TRUST_NO = C.TRUST_NO AND
C.ACCOUNT_PK_SERIAL = B.PK_SERIAL))
AND A.TRUST_NO = 'T110831893'
with temp as (SELECT * FROM trust_info a where a.trust_no='T110831893')
select temp.* from temp
left join trust_account_info on a.trust_no = b.trust_no
where a.service_mode ='01'
union
select temp.* from temp
left join trust_account_info b on a.trust_no = b.trust_no
left join tcms_account_trust_asso c on c.account_pk_serial=b.pk_serial
where a.service_mode ='02'