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

help with sql statement

Status
Not open for further replies.

Deam

Programmer
Joined
Oct 10, 2000
Messages
68
Location
US
There are about 3 phone fields in my table:
WorkPhone = WorkAreaCode + WorkPhone + WorkExtension
MobilePhone = MobileAreaCode + MobilePhone
HomePhone = HomeAreaCode + HomePhone

This is what I had so far...but this statement only displays information if WorkAreaCode,WorkPhone,WorkExtension, MobileAreaCode, MobilePhone, HomeAreaCode, HomePhone are ALL populated.
I want to display phone information...regardless of the fact that there might not be data in the workareacode field or mobileareacode field or any other field. Any help is apprecisted...Thanks in advance.

SELECT CASE WHEN EmpData.WorkPhone IS NOT NULL
THEN 'Work: (' + EmpData.WorkAreaCode + ') ' + EmpData.WorkPhone + ' Ext: ' + EmpData.WorkExtension + CHAR(13) + CHAR(10)
ELSE ''
END +
CASE WHEN EmpData.MobilePhone IS NOT NULL
THEN 'Mobile: (' + EmpData.MobileAreaCode + ') ' + EmpData.MobilePhone + CHAR(13) + CHAR(10)
ELSE ''
END +
CASE WHEN EmpData.HomePhone IS NOT NULL
THEN 'Home: (' + EmpData.HomeAreaCode + ') ' + EmpData.HomePhone + CHAR(13) + CHAR(10)
ELSE ''
END AS Phones
From EmpData
 
You sure you got nulls in the empty fields and not spaces???
 
Nulls in empty fields.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top