Updating using a csv file

I have a mysql database with products in it. I would like to use a csv datafeed to populate the products table. This would need to be updated daily so what is the best way to update the data using a csv file? Some products may have price changes while some new products will need to be added to the table. What is the best way to see if a product id exists, if it does then update that row while if it doesn’t, then add that product to the table.

I figured that using a UPDATE query is not the answer as this will not add any new products so it just a case of finding out if the product id is set and if it is then update the product row? Is there a specified php function for csv files to do something similar to what I want?


Take a look at INSERT … ON DUPLICATE:wink:

thanks for the quick reply, will take a look at it.