select fieldA from tableA a
left outer join tableB b on b.id=a.id and 某一个字段='x'
union
select fieldA from tableA a
left outer join tableC c on c.id=a.id and 某一个字段<>'x'
left outer join tableB b on b.id=a.id and 某一个字段='x'
union
select fieldA from tableA a
left outer join tableC c on c.id=a.id and 某一个字段<>'x'
(select * from a where 某字段='X') A_1
left join tableB b on b.id=a_1.id
left join (select * from a where 某字段<>'X') A_2 on a_1.id=a_2.id
left join tableC C on C.id=a_2.id
@x_int intger
as
select fieldA from tableA a
left outer join tableB b on b.id=a.id where a.fieldB='x'
union all
select fieldA from tableA a
left outer join tableC c on c.id=a.id
where a.fieldB<>'x'
go
select * form
(select * from a where 某字段='X') A_1
left join tableB b on b.id=a_1.id
UNION all
select * from
(select * from a where 某字段<>'X') A_2 left join tableC C on C.id=a_2.id
from tableA a
left outer join tableB b on b.id=a.id and a.某一个字段='x'
left outer join tableC c on c.id=a.id and a.某一个字段='x'
大家还有什么精妙的方法,知无不言啊
from tableA a
left outer join tableB b on b.id=a.id and a.某一个字段='x'
union all
select *
from tableA a
left outer join tableC c on c.id=a.id and a.某一个字段='x'
from tableA a
left outer join tableB b on b.id=a.id and a.某一个字段='x'
union all
select *
from tableA a
left outer join tableC c on c.id=a.id and a.某一个字段='x'
select fieldA
from tableA a
left outer join tableB b on b.id=a.id and a.某一个字段='x'
left outer join tableC c on c.id=a.id and a.某一个字段='x'其实是在此基础上:
select fieldA,“leftt 的某个表中的一个字段值,也是要根据a的某一个字段"x"”
from tableA a
left outer join tableB b on b.id=a.id and a.某一个字段='x'
left outer join tableC c on c.id=a.id and a.某一个字段='x'
可能库设计有点问题,大家包涵啊。
select * from (select * from a where 某字段='X') a
left join tableB b on b.id=a.id
union all
select * from (select * from a where 某字段<>'X') c left join tableC d on c.id=d.id
union all
将两种条件查询的结果联合在一齐楼上几位已经说得很清楚.