T-SQL FULL JOIN

FULL JOIN外联接,不管左表还是右表,只要有记录的,都会列出来。

两张表数据来自http://www.cnblogs.com/insus/articles/1977561.html这里的[Machine]表和[Job]表。

T-SQL FULL JOIN View Code
SELECT  M. [ M_Id ] ,J. [ J_Id ] , [ MachineName ] , [ LineName ] , [ JobNumber ] , [ J_Date ]   FROM   [ dbo ] . [ Machine ]   AS  M
FULL   OUTER   JOIN    -- OUTER关键词是可选的。
[ dbo ] . [ Job ]   AS  J
ON  (M. [ M_Id ]   =  J. [ M_Id ] )

 

执行结果:

T-SQL FULL JOIN

 

你可能感兴趣的:(t-sql)