A表一字段 Col_a 取值 True/False ,对应在 B表及 C表为 Col_b,Col_c想得到 A表中 所有对应在 B,C 中为 True 的记录。(映射关系 A.id=B.id=C.id)亦即,只要 Col_b = true 或 Col_c = true 就选出 A 表对应记录

解决方案 »

  1.   

     select A.* from A
    left join B on a.id=b.id
    left join c on a.id=c.id
    where b.col_b='true' or c.col_c='true'
      

  2.   

    select * from A where exists(select 1 from B where Col_b=A.Col_a) or exists(select 1 from C where Col_c=A.Col_a)
      

  3.   


    select a.*
    from a left join b on a.id = b.id
           left join c on a.id = c.id
    where b.col_b = 'true' or c.col_c = 'true'
      

  4.   

    本帖最后由 roy_88 于 2011-02-23 14:30:58 编辑
      

  5.   


    select a.* from a left join b on a.id = b.id where b.col_b = 'true'
    union
    select a.* from a left join c on a.id = c.id where c.col_c = 'true'