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

Complex query

Status
Not open for further replies.

badger8

MIS
Aug 3, 2001
34
US
I would like to create a query in the query gride view that contains the following criteria:

Contacts that come from specific accounts, titles are blank, email address is blank, in the US, within MA or RI or Part of CT (zip codes that start off with 060, 061, or 062).

How would I create this with the criteria and or row. I just can not create this query and get what I want as a result.

Need help.
 
If I understand:

SELECT *
FROM MyTable
WHERE Title = "" AND
Address = "" AND
ZipCode LIKE "060*" OR
ZipCode LIKE "061*" OR
ZipCode LIKE "062*"

Copy this into the SQL View and then go back to the grid view to see how it sets it up. You may also want to look up the ISNULL function in case the title and address are nulls.

Hope that helps... Terry M. Hoey
 
I think you missed part of the request (within MA or RI). I'm a newbie at home with no references, so I hope my syntax is right ;-)

SELECT *
FROM MyTable
WHERE Title = "" AND
Address = "" AND
State IN ("MA", "RI") OR
ZipCode LIKE "060*" OR
ZipCode LIKE "061*" OR
ZipCode LIKE "062*"

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top