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

Problem filtering list against another DB

Status
Not open for further replies.

Biglop

IS-IT--Management
Aug 16, 2001
25
0
0
US
I have a list of email address in my main database. I also have a list of addresses in another enrollment database. I want to find and send a marketing email to all of the addresses in DB #1 that are not already present in DB #2.

It seems like a simple problem but I'm stumped. Can anybody help?

--Steve
 
Try this:

<cfquery name=&quot;one&quot; datasource=&quot;YourSecondDb&quot;>
SELECT Email
FROM MyTable
</cfquery>

<cfset exclude_emails = QuotedValueList(one.Email)>

<cfquery name=&quot;two&quot; datasource=&quot;YourFirstDb&quot;>
SELECT Email
FROM MyOtherTable
WHERE Email NOT IN (#PreserveSingleQuotes(exclude_emails)#)
</cfquery>

This solution will work, good luck.


<webguru>iqof188</webguru>
 
Thanks, it worked! I hadn't used the QuotedValueList function before. I was trying to use the CF5 queary of queries feature, but wasn't getting anywhere. Could I have don it using that method?

--Steve
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top