title: Update Database table from Excel file
body: <p>I have an excel file which contains many columns. I have two database tables - <code>job_new</code> and <code>job_dockets</code>. 
  I'm trying to create an sql query that pulls two columns from the excel file (JobNo and CustManRef), and updates the field <code>3rdPartyRef</code>from the <code>job_new</code> table but only where the field <code>DocketNo</code>from the <code>job_dockets</code> is equal to the <code>JobNo</code>column from the excel file. </p>
  
  <pre><code>CREATE TEMPORARY TABLE your_temp_table LIKE job_new;
  
  LOAD DATA INFILE 'C:/Users/cdaly/Desktop/test.csv'
  INTO TABLE your_temp_table
  FIELDS TERMINATED BY ','
  (JobNo,CustManRef); 
  
  UPDATE job_new j
  LEFT JOIN job_dockets d on d.JobID = j.ID AND j.CompanyID = 195
  INNER JOIN your_temp_table on your_temp_table.JobNo = d.DocketNo 
  SET j.3rdPartRef = your_temp_table.CustManRef;
  
  DROP TEMPORARY TABLE your_temp_table;
  </code></pre>
  
  <p>The query just keeps saying 0 rows affected, so its not updating the job_new table.</p>
  
  <p>So what I am trying to do is set the <code>3rdPartyRef</code> from <code>job_new</code>to the <code>CustManRef</code> from the excel where <code>docketno</code> from <code>job_dockets</code> is equal to the <code>JobNo</code> column in the excel file</p>
  
  <p>Example of <code>job_docket</code>:</p>
  
  <p><a href="https://i.stack.imgur.com/l9edP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/l9edP.png" alt="enter image description here"></a></p>
  
  <p>Example of <code>job_new</code>:</p>
  
  <p><a href="https://i.stack.imgur.com/fuGvW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fuGvW.png" alt="enter image description here"></a></p>
  
  <p>Excel file:</p>
  
  <p><a href="https://i.stack.imgur.com/nAiUo.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nAiUo.png" alt="enter image description here"></a></p>
  
  <p>Ok I hope these examples make it clearer. 
  So the <code>JobNo</code> from the excel file is equal to the <code>DocketNo</code> from <code>job_dockets</code>. So when the <code>JobNo</code> is equal to the <code>DocketNo</code> I then need to update the <code>3rdPartyRef</code> from <code>job_new</code> to the <code>CustManRef</code> from the excel.  </p>