title: mysql LOAD DATA INFILE update
body: <p>I am currently using mySQL LOAD DATA INFILE to insert a csv file into my database. This csv file is downloaded to the server on a daily basis in order to keep product data up-to-date.</p>
  
  <p>What I want to know is how can I update the table with the new csv and preserve the existing data where it's not different?</p>
  
  <p>Here is my current statement:</p>
  
  <pre><code>LOAD DATA LOCAL INFILE '$file' REPLACE INTO TABLE products FIELDS TERMINATED BY ',' ENCLOSED BY '\"' ESCAPED BY '\\\' IGNORE 1 LINES (aw_product_id,merchant_id,merchant_image_url,aw_deep_link,description,in_stock,merchant_name,brand_name,display_price,product_name,rrp_price,merchant_category
  </code></pre>
  
  <p>This works fine but it replaces the ID column with a completely new set and also reverts columns that I want to ignore, back to the default state. For example I have a column called 'Published' with a value of 0 or 1. If I use REPLACE it sets that column back to 0.</p>
  
  <p>How can I use REPLACE but ignore some columns?</p>