select A1.M, A1.N, A2.N from A1 left join A2 on A1.M = A2.M
union all
select A2.M, null, A2.N from A2 where not exists(select 1 from A1 where A1.M = A2.M)
union all
select A2.M, null, A2.N from A2 where not exists(select 1 from A1 where A1.M = A2.M)
union
select A1.M,A1.N,B1.M,B1.N from A1 RIGHT JOIN B1 ON ON A1.M=B1.M
如果还想多一点判断,还可以在Column前面加iif的判断,比如为空就置0
比如iif(A1.N is null,0,A1.N)
这样可以吗,可以的话要记得给分哦,hoho
select A1.M, A1.N, A2.N from A1 ,A2
where A1.M = A2.M(+)
union
select A2.M, A1.N, A2.N from A1 ,A2
where A1.M(+) = A2.M