有两个表,进行关联,第一个条件关联之后,没有关联上的,用第二个条件在进行关联,这种有什么方法吗
还有存在关联不上的???
select
....
from table a with (nolock)
left join table2 b on a.id=b.id
left join
(select
...from table3 c with (nolock)
left join table4 d on c.id=d.id
where ......
)as t on t.id=a.id
就是or呗
select a.*,b.* from 表a a left join 表b b on
a.a1=b.b1
or
a.a2=b.b2
这样第一个关联不上,第二个能关联上,也行
select * from a,b where a.a1=b.b1 or a.a2=b.b2