Constituent Queries To-Go, Part 2: How to Query on Zip Codes

Published
Let’s think about Zip Codes.  Back in the old days, we all had a 5 digit zip codes, but now, we have a 5 digit zip code plus an optional 4 extra digits.  This helps the Postal Service in automating the mail delivery, and allows for faster delivery and more accurate processing of mail.  Those are all good things, but it changes the way a zip code is read in software like The Raiser’s Edge.  When a zip code was 5 digits, it was a number and we could query for records in a range using criteria like this:

Zip Code between 46225 and 46228:

Preferred Zip BETWEEN 46225 and 46228

If you have records that have the 5-digit zip code plus 4 digits, those records would not appear in the results of this query.  46228-1445 is not a true number value, but a text value because of the dash.  So we need to create our query a little differently so we can get these records into the results of our query too.

The best way to do this is to use a wild card (*) within the criteria and select the criteria multiple times.  Note: We cannot use the One Of operator in query if we are using a wildcard - we must use the Equals or Begins With operator.  Using the same end goal of finding Constituent records with a zip code between 46225 and 46228, we need 4 lines of criteria now:

4 lines of 'Preferred Zip equals'

You can see I have selected Preferred Zip and set the operator to Equals and entered a value of 46225*.  The * (asterisk) is a wild card.  It tells the query to look for any record that has 46225 and anything after it, regardless of what is after it.  So this criteria would give me records that have 46225 alone or 46225-1234, 46225-1235, 46225-1236, etc.  I have to add Preferred ZIP again for 46226* and 46227* and 46228* to get each one as an individual line of criteria with their own wild card.  Notice how there is an OR between each line.

What if I wanted all records with zip codes between 46220 and 46229?  I can use the wildcard more efficiently in this example.  I want any record where the zip code starts with 4622, so my criteria would look like this:

Preferred zip equals 4622*

OR it could look like this:

Preferred zip BEGINS WITH 4622*

Both ways would give me the results I need.

query results

This Knowledgebase article will be a great resource on this topic too: How to query on ZIP Code

This query gives us Constituent records based on specific zip codes within a range, including records with +4 zip codes.  Our next blog in this 4-part series will focus on finding records that are Head of Household within a query.  Stay tuned!

To learn the basics of query, take the Raiser’s Edge: Fundamentals-Query 1 class. To take your query knowledge to the next level, take the Raiser’s Edge: Query 2 class.
News Raiser's Edge® Blog 11/10/2015 9:24am EST

Leave a Comment

Check back soon!

Share: