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

Jan Schneider jan at horde.org
Thu Aug 28 14:01:33 PDT 2003


Zitat von Stephen Warren <swarren at wwwdotorg.org>:

> 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!

Make one of the columns 10 chars shorter.

Jan.

--
http://www.horde.org - The Horde Project
http://www.ammma.de - discover your knowledge
http://www.tip4all.de - Deine private Tippgemeinschaft


More information about the turba mailing list