• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Insert row replacing

 
MichaelJ McCabe
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please excuse my lack of MySql knowledge here.

Basically, every day I have a CSV file with a weeks worth of data. And every day that passes by, the csv files is automatically edited and removed the last day and adds the new day. So that it always has the LAST weeks data.

I need to parse this data and put it into a database.

The problem is here, obviously, is that if I just parse this data in, there will be duplication. Every day, im adding a new set of data which I parsed for the last 6 days, even though it is identical. Mysql will take a new primary key and add this in as seperate content.

I know the simple answer is to check that the data isnt already there, or to make sure that I only parse the LAST day. But I was thinking to myself, why complicate things, if there was a way of overwritting the data if there is a duplication?
 
Fatih Keles
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Michael,

If you can identify a row with some unique constraint mysql offers this and it may help.
For further discussion you may find these useful, mostly the second one

mysql-merge-gone-awry
multi-row-merge-in-mysql

Regards,

Fatih.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic