Reputation: 2680
The example below shows the result for every Name
that has a connection to Table2 (Table1 TId
is PK, and TId
in Table2 is the FK).
SELECT T1.Name, T1.Address
FROM Table1 AS T1
INNER JOIN Table2 AS T2
ON T1.TId = T2.TId;
I want a list of all Names from Table1
that have NO corresponding row in Table2
. The other way around so to speak. How could this be done?
Upvotes: 0
Views: 139
Reputation: 7600
You need to use an Outer Join
as shown below:
SELECT T1.Name, T1.Address
FROM Table1 AS T1
LEFT OUTER JOIN Table2 AS T2 ON T1.TId = T2.TId
WHERE T2.TId IS NULL
Upvotes: 2