I created two tables below, and FK_TypeID is nullable in this case. I want to write a query returning me the join of two tables.
if FK_TypeID is NULL for a certain row, the TypeName is also NULL. I am not sure how to go about creating such join statement?
[Actions]
ActionsID
Date
Message
FK_TypeID //links to the table below
[Type]
TypeID
TypeName
My current statment looks like this and it simply skips NULL FK_TypeID rows
SELECT *
FROM Actions
INNER JOIN TypeName ON Actions.FK_TypeID = [Type].TypeID
Help would be greatly appreciated!
You just need to use a
LEFT JOINIf a match to
Actionsis not found to tie it withType, then all columns inTypewill beNULL.Here is a good graphical visualization of the different types of joins in SQL