Full outer join in SQL
January 19, 2023 2023-01-22 20:17Full outer join in SQL
The FULL OUTER JOIN keyword returns all records when there is a match in left (CAR) or right (COLOR) table records.
FULL OUTER JOIN and FULL JOIN are the same.

When no matching rows exist for the row in the left table, the columns of the right table will contain NULL. Likewise, when no matching rows exist for the row in the right table, the column of the left table will contain NULL.
Let there be two table, CAR as follows

and COLOR as follows

Now, if we run a full outer join in the above two tables, as follows
SELECT [CAR].[Name] as CarName, COLOR.[Name] as ColorName FROM [CAR] FULL OUTER JOIN [COLOR]
ON [CAR].ColorId = [COLOR].ColorId
we will get the following result,

In the above result it can be seen that all the matched columns from both the table has been retrieved along with the unmatched rows from both the table. The left and the right column contain the NULL values for the unmatched rows.
Please comment and share if you like this post and tell us about how we can enhance our posts in dotnetcoaching. Thanks.
Subhajit
Search
Popular posts
