Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Joining two Tables

Status
Not open for further replies.

Edwardjm

MIS
Sep 1, 2000
5
0
0
US
Help Please!

I'm trying to join two tables together where data in the second table may or may not exist. It only works when there is matching data in the second table but not when the key is null.

Please advise what I am doing wrong?
 
When you say it only works when there is matching data in the second table, by "works" I assume you mean you don't get any data.

If you want to return all of the rows from the first table, and matching rows if they exist from the second table, what you want is an outer join.

[tt]select TableA*, TableB.WhateverColumns
from TableA left join TableB on
(TableA.FK = TableB.PK) [/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top