select x.a,y.e,y.f,x.c,x.d from x,y where x.b=y.b --楼主没说连接条件,这个条件是猜测的 and (x.a符合條件1 or not x.a符合條件1 and x.b符合條件2 )
希望能看明白,或者这样实例化select x.a,y.e,y.f,x.c,x.d from x,y where x.b=y.b --楼主没说连接条件,这个条件是猜测的 and (x.a=1 or x.a<> 1 and x.b=2 )
if exists(select 1 from X where A=@A) select * from X where A=@A else select * from Y where B=@B
if exists(select 1 from x left join y on x.b=y.b where 条件一) select a,e,f,c,d from x left join y on x.b=y.b where 条件一 ELSE select a,e,f,c,d from x left join y on x.b=y.b where 条件二
from x,y
where x.b=y.b --楼主没说连接条件,这个条件是猜测的
and (x.a符合條件1
or not x.a符合條件1 and x.b符合條件2
)
from x,y
where x.b=y.b --楼主没说连接条件,这个条件是猜测的
and (x.a=1
or x.a<> 1 and x.b=2
)
select * from X where A=@A
else
select * from Y where B=@B
select a,e,f,c,d from x left join y on x.b=y.b where 条件一
ELSE
select a,e,f,c,d from x left join y on x.b=y.b where 条件二