• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

Insert row replacing

 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic