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

Query question

Status
Not open for further replies.

jpeasemiller

Technical User
Feb 22, 2002
14
US
I have access 2000....Want to exclude certain cities from my CITY field and possibly some zip codes from that field.

What is the proper syntax in a Query to accomplish this? Then I want to save the results so that I can do a mail merge with Word 2000.

Could this exclusion also be accomplished with filtering or sorting?
 
To exclude certain criteria you need to use a NOT clause. These aren't very efficient though. If possible try to write your criteria so as to avoid the use of NOT
(i.e. To exclude all NN postcodes you could use:
Postcode Not Like "NN*"
or
Left(Postcode, 2) < &quot;NN&quot; Or Left(Postcode, 2) > &quot;NN&quot;
)

The second option is more efficient than the first.
 
<> is as inefficient as it is the same as Not but < and > can use the indexing (providing it is setup) as it evaluates the duality of the statement. Not (or <>) evaluate each row.
 
Interesting! (I have a boss that uses the &quot;<>&quot; symbols often in his formulas.)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top