如图,B和C是A表的子表,现在我想将A\B\C三表一条sql语句查询出来,,目前通过关联left join查询出来,结果为D表,我想实现E表的效果,该怎么写语句呢?
select A.ID,A.名称,BC.等级A,BC.等级B
from A
left join (select AID,等级A,null as 等级B
from B
union all
select AID,null as 类别A,等级B
from C
) BC on A.ID =BC.AID