Rhino wrote:

----- Original Message ----- From: "Rob Kudyba" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, November 04, 2004 12:26 PM
Subject: constructing a select and excluding duplicates





I am trying to construct a SELECT statement on distinct email addresses.
Our DB has emails entered by various sources and there are duplicate
addresses based on the source. Using sample table names and sources here
is what I have:

SELECT  DISTINCT email_address
FROM  'email_table'
WHERE SOURCE =  'source 1'

Simple enough, but I want to exclude email addresses that appear in
several other sources, i.e, something like in this pseudo sample:

SELECT  DISTINCT email_address
FROM  [ENTIRE_TABLE_IN_DATABASE]
WHERE SOURCE =  'source 1'
AND EXCLUDE email_address IF SOURCE = [source 2, source 4, source 6]



Wouldn't it make a lot more sense to get rid of your duplicates FIRST? That
is going to dramatically simplify your life for every other query you do.
It's also going to reduce the size of your tables which should improve query
performance and reduce hard disk usage.



Fair enough question and the answer is that depending on the source, the contents of the email will differ based on the product we are marketing, since we offer several. Some times the source is similar enough where we can use the same marketing message too...so in this case I wanted to avoid soliciting folks that already received a similar mail but a different source. Source in our case means different places where users opted in to receive mails, whether it's our customer list of folks who purchased a product, downloaded a trial, a person we met at a conference, etc...

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]



Reply via email to