On Tue, Jun 24, 2008 at 2:14 PM, Ben Reece <[EMAIL PROTECTED]> wrote:
> INSERT INTO List1 (name, email, unsubbed) (SELECT name, email, 'N' FROM
> List2 LEFT JOIN List1 ON List2.email = List1.email WHERE List1.email IS
> NULL)
>
> That should prevent it from inserting any email address from List2 that's
> already in List1.

A better solution to prevent duplicates is to enforce the uniqueness.
Add a UNIQUE key for the email address column.  This will prevent all
duplicates all the time.

With that in place combining the list is even simpler:
INSERT IGNORE INTO List1 (name, email, unsubbed) (SELECT name, email,
'N', FROM List2)

That will just ignore rows that duplicate the email address.

_______________________________________________

UPHPU mailing list
[email protected]
http://uphpu.org/mailman/listinfo/uphpu
IRC: #uphpu on irc.freenode.net

Reply via email to