T-SQL FULL JOIN
FULL JOIN外联接,不管左表还是右表,只要有记录的,都会列出来。
两张表数据来自http://www.cnblogs.com/insus/articles/1977561.html这里的[Machine]表和[Job]表。
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
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])
FULL OUTER JOIN --OUTER关键词是可选的。
[dbo].[Job] AS J
ON (M.[M_Id] = J.[M_Id])
执行结果: