sql中的全外联区别与左联接与右联接,它会按将on语句指明的条件,将左表与右表两个表的所有记录都查询出来,没有值的字段返回null,全外联的关键字是full outer join,下面是全外联的一个sql示例:
select h.RKNumber,isnull(h.GID,i.GID)as GID,i.GID as GID1,i.CKNumber from (
select Sum(c.Number) as RKNumber,c.GID from
(select b.GID,b.Number from Storage_RKMaster a left join Storage_RKDetail b
on a.RKID=b.RKID where b.GID is not null) c Group by c.GID
) h full outer join
(
select Sum(g.Number) as CKNumber,g.GID from
(select f.GID,f.Number from Storage_CKMaster e left join Storage_CKDetail f
on e.CKID=f.CKID where f.GID is not null) g Group by g.GID
) i on h.GID=i.GID