Exclude Duplicate Data

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Hello MySQL Gurus -

I have 3 tables:

all_customers, opt_out_customers, and opt_in_customers

Let's say there's an id column and an email_address column in each.

I'm sending a newsletter - I want to send it to:

all_customers except where opt_out or opt_in
opt_in except where in all_customers (so as not to send it twice)

I have to use MySQL 4.0. (no sub-selects, etc.)

I had previously tried with a 'LEFT JOIN' but it only seemed to work to
exclude one or the other (e.g. where NULL). Might a 'UNION' work here?

Thanks for any info / examples.


Site Timeline