MySQL Forums
Forum List  »  InnoDB

ON DUPLICATE KEY UPDATE usage
Posted by: Jamie Condliffe
Date: November 08, 2005 07:37AM

Hi all,

I'm working on Windows 2003 server with mySQL 4.1.

I'm currently writing a VBScript that pulls down articles written for our company from an XML feed and stores them in a database.

The articles in the feed have an unique id, and sometimes the article is modified once it is published to the feed. The feed is 'queue' based, so articles remain in the feed until it is full, then the oldest article is removed as the new one is added, ad-infinitum.

To deal with the multiple issues of avoiding duplication in the database, and updating existing articles in the database, I made the 'OriginalID' column unique in the schema (this is the id of the articles as provided in the XML feed), as well as my own autoincrement 'ID' column. I then wrote the following SQL Query. However, I am not too confident about my useage of the 'ON DUPLICATE KEY UPDATE' feature. I'd be grateful for any comments.

INSERT INTO articles ( OriginalID , SourceID , Created , Headline , Article , ArticleSummary , PictureURL , PictureURLSmall )
VALUES( ... )
ON DUPLICATE KEY UPDATE Headline=VALUES(Headline), Article=VALUES(Article), ArticleSummary=VALUES(ArticleSummary), PictureURL=VALUES(PictureURL), PictureURLSmall=VALUES(PictureURLSmall);

Thanks in advance for your comments.

- Jamie

Options: ReplyQuote


Subject
Views
Written By
Posted
ON DUPLICATE KEY UPDATE usage
2408
November 08, 2005 07:37AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.