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'

解决方案 »

  1.   

    select * form 
    (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
      

  2.   

    create proc pro_1
     @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
     
      

  3.   

    更正一下:
    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
      

  4.   

    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'
      

  5.   

    真是一头棒喝啊,thanks a million.
    大家还有什么精妙的方法,知无不言啊
      

  6.   

    select *
    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'
      

  7.   

    select *
    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'
      

  8.   

    接着:
    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'
    可能库设计有点问题,大家包涵啊。
      

  9.   


    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
      

  10.   


    union all
    将两种条件查询的结果联合在一齐楼上几位已经说得很清楚.