Scott:

Yeah, exactly. The ON DUPLICATE KEY is useful if your table has something like a "last modified" or "last accessed" column that is relevant for what you're doing. It is just an easier way to accomplish INSERT IGNORE plus then doing an UPDATE on all the rows that got ignored, in case you need to document that there was an attempt to insert the data.

Wes

On Jul 21, 2004, at 12:58 AM, Scott Haneda wrote:

on 7/20/04 9:44 PM, Wesley Furgiuele at [EMAIL PROTECTED] wrote:

First off, the unique index is something you define for the table once.
Being unique, you won't be allowed to add in another record with the
same values as an record that already exists in the table.

I thought so, thanks.

And yes, once you set it up, INSERT IGNORE would allow your query to
simply skip the insertion of any records that already exist in the
table. Something else to look at would be the INSERT ... ON DUPLICATE
KEY UPDATE syntax, depending on your version of MySQL ( >= 4.1 )
http://dev.mysql.com/doc/mysql/en/INSERT.html

Super, so the INSERT IGNORE is gonna work. Curious why you pointed me to
the ON DUPLICATE KEY link. Since I want to just gracefully exit from the
insert, I assume you were just pointing this out as a FYI? This feature is
more or less if I wanted to make some update to a row when the duplicate was
hit?


I'm not yet sure yet what to make of your last situation, where you are
merging addresses into one group. About the bounce count, presumably
that is not necessarily the same value for each instance of an email
address across different groups? Is the bounce count the only field
that would differ between the two duplicate records?

To be honest, I am not entirely sure, yet, this will require me to ponder
some more about how this is going to work.


Thanks for all your help so far, this is a great solution to a otherwise
complicated to me issue :-)


--
-------------------------------------------------------------
Scott Haneda                                Tel: 415.898.2602
http://www.newgeo.com                       Fax: 313.557.5052
[EMAIL PROTECTED]                            Novato, CA U.S.A.



--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]





--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]



Reply via email to