INSERT...ON DUPLICATE ROW

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
kendall
Forum Regular
Posts: 852
Joined: Tue Jul 30, 2002 10:21 am
Location: Trinidad, West Indies
Contact:

INSERT...ON DUPLICATE ROW

Post by kendall »

Is there any MYSQL Syntax that will allow me to Insert records and Either append or update records based on the matching values of a ROW rather than a UNIQUE or PRIMARY KEY?
User avatar
kendall
Forum Regular
Posts: 852
Joined: Tue Jul 30, 2002 10:21 am
Location: Trinidad, West Indies
Contact:

Re: INSERT...ON DUPLICATE ROW

Post by kendall »

Well I knew about this but the thing is the primary Key is a auto incremented and the other columns can contain duplicates. The data is not going to have the auto incremented field. So i need to match the VALUES of the WHOLE ROW except the auto increment column.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: INSERT...ON DUPLICATE ROW

Post by John Cartwright »

I don't fully understand what you are trying to do.

If a row matches exactly with some input you have, you want to update? This will involve two queries.
User avatar
kendall
Forum Regular
Posts: 852
Joined: Tue Jul 30, 2002 10:21 am
Location: Trinidad, West Indies
Contact:

Re: INSERT...ON DUPLICATE ROW

Post by kendall »

Jcart wrote:I don't fully understand what you are trying to do.

If a row matches exactly with some input you have, you want to update? This will involve two queries.
yeah thought so...

the client is extracting data from a database for my cron job to insert into mysql...they are lazy and rather than just give me the new data...they are giving me data that may contain redundant records. I had a unique id that i could have used but they have sinced changed thier format and no not only do i have to append new information but I will need to identify changes in the old data to have it updated where necessary..

sigh...clients....
Post Reply