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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

join with no ID or NULL 1

Status
Not open for further replies.

gatetec

MIS
Mar 22, 2007
420
0
0
US
I have demo & visit tables.
But, not all client IDs are on both tables.
I want to return all of records on tbl Visit and then join to tbl Demo if Client IDs exist on both tables.

select d.ClientNo, d.ClientFName, d.ClientLName, v.VisitDate
from demo d, Visit v
where d.ClientNo= v.ClientNoVisit
order by d.ClientLName, v.VisitDate

thx much
 
Use an outer join.

Code:
SELECT d.ClientNo, d.ClientFName, d.ClientLName, v.VisitDate
FROM Visit v
LEFT OUTER JOIN Demo d
ON v.ClientNoVisit = d.ClientNo
ORDER BY d.ClientName, v.VisitDate
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top