select bl.name as w,bp.name as wa from c_order c
left outer join C_BPARTNER bp on bp.C_BPARTNER_ID=c.C_BPARTNER_ID
left outer join C_BPARTNER_LOCATION bl on bl.C_BPARTNER_LOCATION_ID=c.C_BPARTNER_LOCATION_ID
// 一个sql , 里面只会有一条数据,当条件为真时。
select * from c_bpartner db where db.ismajor='Y'
求求求
------解决方案-------------------- select * from (select bl.name as w,bp.name,bp.ismajor as wa from c_order c
left outer join C_BPARTNER bp on bp.C_BPARTNER_ID=c.C_BPARTNER_ID) t left join C_BPARTNER_LOCATION bl on bl.C_BPARTNER_LOCATION_ID=c.C_BPARTNER_LOCATION_ID where t.ismajor='Y' ------解决方案-------------------- select bl.name as w,bp.name as wa from c_order c
full join C_BPARTNER bp on bp.C_BPARTNER_ID=c.C_BPARTNER_ID
left outer join C_BPARTNER_LOCATION bl on bl.C_BPARTNER_LOCATION_ID=c.C_BPARTNER_LOCATION_ID
------解决方案-------------------- select * from c_order c
left join C_BPARTNER pn on pn.C_BPARTNER_ID=c.C_BPARTNER_ID
left outer join C_BPARTNER_LOCATION bl on bl.C_BPARTNER_LOCATION_ID=c.C_BPARTNER_LOCATION_ID
union all
select * from c_order c
where exists(select 1 from c_bpartner db where db.ismajor='Y' and db.C_BPARTNER_ID=c.C_BPARTNER_ID)
没太懂你的需求。。
------解决方案--------------------
试试这个吧。 ------解决方案-------------------- 还是考虑一下用存储过程吧 ------解决方案-------------------- 为什么不在查出来的结果里面decode呢 ------解决方案-------------------- select * from c_order c
left join C_BPARTNER pn on pn.C_BPARTNER_ID=c.C_BPARTNER_ID
left outer join C_BPARTNER_LOCATION bl on bl.C_BPARTNER_LOCATION_ID=c.C_BPARTNER_LOCATION_ID
union all
select * from c_order c
where c.issotrx='Y' ------解决方案-------------------- select C.* from c_order c
left join C_BPARTNER pn on pn.C_BPARTNER_ID=c.C_BPARTNER_ID
left outer join C_BPARTNER_LOCATION bl on bl.C_BPARTNER_LOCATION_ID=c.C_BPARTNER_LOCATION_ID
union all
select C1.* from c_order c1
where c1.issotrx='Y' ------解决方案--------------------