ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to handle second table with no values. (https://www.excelbanter.com/excel-programming/433381-how-handle-second-table-no-values.html)

DG

How to handle second table with no values.
 
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



fred

How to handle second table with no values.
 
Try

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

Fred

"DG" wrote in message
...
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





DG

How to handle second table with no values.
 
Thanks Fred that did the trick

Dan

"Fred" <leavemealone@home wrote in message
...
Try

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

Fred

"DG" wrote in message
...
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








All times are GMT +1. The time now is 02:32 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com