How to handle second table with no values.

  • Thread starter Thread starter DG
  • Start date Start date
D

DG

Let's say I have two tables Names and PhoneExt

Names Table
Name
Bob
Larry
Sue
Tammy

PhoneExt table:
NAME EXT
Bob 3456
Larry 3458
Tammy 3463


SELECT n.NAME, p.EXT
FROM Name n, PhoneExt p
Where n.NAME = p.NAME

The result would leaves out Sue. How do I write this statement to include
"N/A" for Sue. Not sure if it is COALESCE or ISNULL. Or how to use it if
it was.

Dan
 
Try

SELECT n.NAME, p.EXT
FROM Name.n
LEFT JOIN PhoneExt p
ON p.NAME=n.NAME

Fred
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top