指定bb,cc为驱动表试验一下。

解决方案 »

  1.   

    select flg, id
              from bb
             where exists (select 1
                      from aa
                     where aa.flg = '1'
                       and aa.id = bb.id)
            union all
            select flg, id
              from cc
             where exists (select 1
                      from aa
                     where aa.flg <> '1'
                       and aa.id = cc.id)会不会快点?