Merging Queries Makes Everything Better
Degree of difficulty in query depends on how refined your criteria needs to be.
For example, if you need to send mail to all of your constituents whose Preferred City is Charleston, your query criteria is nice and simple:
Preferred City equals Charleston.
Of course, it usually isn't that easy. You're more likely asked to send mail to everyone with a Preferred City of Charleston who has given a cumulative amount of $100 or more, except for anybody who is a Board Member, or who has a Solicit Code of either Do Not Mail, Do Not Solicit, or Leave Me Alone, or who gave their first gift in this calender year.
While it is possible to do all of this in one query, weaving together the necessary combination of ANDs, ORs, parentheses, and negative operators required to group all of these records in one query is an aggravating, time-consuming process.
The best solution is to create two queries. The first query (Query A) would include the records that meet the overarching criteria you're searching on. In this scenario, Query A would look like this:
Preferred City equals Charleston
AND Summary Information, Total Amount greater than or equal to $100
The flip side would be to capture all the records you are trying to suppress in another query (Query B), which would look like this:
Constituency Code equals Board Member
OR Solicit Code one of Do Not Mail, Do Not Solicit, Leave Me Alone
OR First Gift Date equals This Calendar Year
Once these queries have been created, saved, and given nice, memorable names, it's time to get this merge party started. "Merge" is actually a bit of a misnomer here. The two source queries are not combined into an inextricable whole. Rather, Query A and Query B will serve as parent queries to create Query C, a third, child query.
Click the Merge queries button at the top of the Query screen. Select Query A as the Primary Query and Query B as the Secondary Query. Next, select the Operator of SUB and click OK.
SUB, in this instance is not an abbreviation for either a sandwich chain, a form of mass transit, or an underwater boat. In this case, it's short for "subtract". The merge will subtract the records in Query B from the group in Query A.
Don't worry if the number of records in your merged query do not match the difference between your two queries. There may be records that meet the criteria in Query B but not in Query A. Those records won't be subtracted from Query A because they aren't there to be subtracted. Only records that meet the criteria of both queries will be excluded.
If you would like to learn more about merged queries, check out knowledgebase solution
BB513.