oracle写sql语句

wangcangju110 2017-07-11 01:56:33
select * FROM trust_info a,trust_account_info b,tcms_account_trust_asso c
where (case when a.service_mode =' 01' then a.trust_no = b.trust_no when a.service_mode =' 02' then a.trust_no=c.trust_no and c.account_pk_serial=b.pk_serial end) and a.trust_no='T110831893'

这个写法错误 该怎么改呢 !想达到效果a表字段trust_no为01链表a和b,a表字段trust_no为02链表a,b,c
...全文
186 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
chengccy 2017-07-11
  • 打赏
  • 举报
回复
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'
alex259 2017-07-11
  • 打赏
  • 举报
回复
直接union不行吗?
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'

17,089

社区成员

发帖
与我相关
我的任务
社区描述
Oracle开发相关技术讨论
社区管理员
  • 开发
  • Lucifer三思而后行
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧