我有一个很长的配置单元查询,它有10个连接和很多条件,下面是3个条件
1) If id is not equal to XFG or GHT, use field sid
join ABC_Tables on sid
join CDE_Tables on sid
2) If id is equal to XFG or GHT, Tested is null, use field pid
join ABC_Tables on kid
join CDE_Tables on kid
3) If id is equal to XFG or GHT, Tested is not null, use field pid
join ABC_Tables on kid
join CDE_Tables on kid
我在做什么,
select 1 conditions
union all
select 2 conditions
union all
select 3 conditions
我做得对吗。以上问题的替代方案是什么。
1条答案
按热度按时间zfycwa2u1#
你的条件是允许的
ON
联接条件。配置单元中允许等于/不等于常量( ID!='XFG')and(ID!='GHT')and(a.PID=b.PID)
是允许的联接条件。a.ID not in ('XFG', 'GHT') and a.sid=b.sid
也应该起作用: