in reply to Re: MySQL and Duplicate Keys
in thread MySQL and Duplicate Keys

Well, perhaps a bit of reasoning. It may clear up some things.
First off, let's make an assumption. Every book published in the US has an ISBN number which is guaranteed to be unique. I'd use that for my primary key.
A theoretical fill-in form could ask for ISBN number, a title, a price, maybe an author, etc. I figured I could use an INSERT statement to allow them to input their own data. In the event that a book had already been entered with an ISBN, it would simply update that old record, as is documented.
I figured I could have MySQL do the work for me by using INSERT with ON DUPLICATE KEY instead of doing a bunch of checking to see if that book was already entered, etc. and doing an UPDATE/SET on the record where that key was. Basically, I just thought I'd found a way to be lazy.
The "ISBN" is the only key, and the only unique column.

I guess my syntax would be
my $sth = $dbh->prepare("INSERT INTO listings (isbn,price,author) VALUES ($isbn,$price,$author) ON DUPLICATE KEY UPDATE [whichever values, yada yada]
Perhaps this is not an advisable way of doing this?