title: Query to insert rows from CSV to MySQL
body: <p>I have 2 tables <code>employees</code> and <code>job</code> in a <code>MySQL</code> server. I have 2 <code>CSV</code> files with the same schema as the two tables. Something as below.</p>
  
  <p><strong>Job table(MySQL)</strong></p>
  
  <p><a href="https://i.stack.imgur.com/D5xqP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/D5xqP.png" alt="enter image description here"></a></p>
  
  <p><strong>Job(CSV)</strong></p>
  
  <p><a href="https://i.stack.imgur.com/MCGOm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MCGOm.png" alt="enter image description here"></a></p>
  
  <p><strong>Employees(MySQL)</strong></p>
  
  <p><a href="https://i.stack.imgur.com/nd7Hn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nd7Hn.png" alt="enter image description here"></a></p>
  
  <p><strong>Employees(CSV)</strong></p>
  
  <p><a href="https://i.stack.imgur.com/wKdco.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wKdco.png" alt="enter image description here"></a></p>
  
  <p>I need to insert the rows from <code>CSV</code> into the <code>MySQL</code> tables. Note that the <code>Id</code> fields in both the tables are on <code>AUTOINCREMENT</code>. I am aware that <code>MySQL</code> does not support <code>merge</code> query and instead has <code>INSERT.. ON DUPLICATE UPDATE</code>. Now the issue with using this is that the Primary keys i.e., the Ids are definitely duplicate but I need them to be inserted as new rows with new Ids. For example, the Admin role should have the Id as 3 and so on. Also, as you can see, the <code>job</code> table is being referenced by the <code>employees</code> table. So the the <code>JobId</code> column in the table should be updated with the respective values. I am not sure how this can be achieved.</p>
  
  <p>Any help appreciated!</p>