[UPHPU] Update a mysql table.
Lonnie Olson
lists at kittypee.com
Thu Jun 26 09:43:50 MDT 2008
On Tue, Jun 24, 2008 at 2:14 PM, Ben Reece <breece at doba.com> 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.
More information about the UPHPU
mailing list