select * from ((select * from 表一 where type=1 and status=1) aa join (select * from 表二 where status=1) bb on aa.typeid=bb.aid) tem1
union all
select * from ((select * from 表一 where type=2 and status=1) cc join (select * from 表三 where status=1) dd on cc.typeid=dd.aid) tem2

解决方案 »

  1.   


    select * from (select * from (select * from 表一 where type=1 and status=1) aa join (select * from 表二 where status=1) bb on aa.typeid=bb.aid) tem1
    union all
    select * from (select * from (select * from 表一 where type=2 and status=1) cc join (select * from 表三 where status=1) dd on cc.typeid=dd.aid) tem2