[turba] MySQL table - insert if doesn't exist already?

Stephen Warren swarren at wwwdotorg.org
Thu Aug 28 11:35:49 PDT 2003


A related question to my last question:

Is there a way, in a single SQL statement, to insert new entries into the
turba object table (Turba 1.2 MySQL schema) *but* not insert if the
combination is already present?

At various points in time, I want to automatically add a tuple (recipient,
sender) as (owner, email_address) from an email that I've received into
the Turba contact list, *but* only if that owner doesn't already have a
contact in the address book with that email address.

As a quick hack, I thought about defining a unique key on the combination
of (owner, email_address) - and then using the IGNORE option on the SQL
INSERT to ignore duplicate key errors, and throw away the INSERT - but
MySQL limits the key size to 500, but the combination of those columns is
510 chars!

Anyone got any clever ideas?

Thanks.

-- 
Stephen Warren, Software Engineer, Parama Networks, San Jose, CA
swarren at wwwdotorg.org                  http://www.wwwdotorg.org/


More information about the turba mailing list