distinct emails from multiple tables

wxdqz

New Member
I have a form with a select box where the user can choose multiple tables of a database, each containing an email field, and I would like a script to generate the appropriate sql query to select email addresses from the chosen tables but whitout having more than one time the same address (some can be present in more than one table) in the resultset for the mailing.

I tried a bit and got a script to output a query like this:
<i>select distinct(newsletter.email) from newsletter left join profiles on newsletter.email = profiles.email where newsletter.lang = 'de' OR profiles.language = 'de'</i> with newsletter.email being the email field of the last table name the script looped through. But this solution only returns email addresses of this last table.

Any ideas on how to achieve this?
Thanks in advance.
- Jean-Marc
 
Back
Top