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!

Combinations in the where clause - Query

Status
Not open for further replies.

sd110404

Programmer
Nov 3, 2004
63
US
Hi,

Let me just brief the pbm.

Lets take customer table with fields Customer ID, name, homePh, cellPh, workPh

I want to display only those customer name who have only one phone number or no phone number (it can be in any combinations, like the customer might have only cellPh or only homeph, or only workPh).

Is there any other way, other than mentioning the combinations in the where clause.

Thanks in advance.

 
SELECT * FROM tblCustomer
WHERE (IIf(Trim(homePh & "")="",0,1)+IIf(Trim(cellPh & "")="",0,1)+IIf(Trim(workPh & "")="",0,1))<=1

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top