title: How to update sql column with an array?
body: <p>I've input as <code>employee</code> table, <code>emp_ids</code> array and <code>emp_joining_dates</code> array. My Employee table has 3 columns, <code>emp_id</code>, <code>emp_name</code> &amp; <code>emp_joining_date</code>. Table has more than 10k records. I need to update <code>emp_joining_date</code> for <code>emp_ids</code> listed in input array.</p>
  
  <p>I was able to achieve this by for-loop, as follows,</p>
  
  <pre><code>for 0 &lt; i &lt; emp_ids.length
   update employee set emp_joining_date = emp_joining_dates[i] where emp_id = emp_ids[i] //running update query multiple times
  end
  </code></pre>
  
  <p>The problem with above approach is that I'm hitting db with multiple queries. Can I achieve same thing using single query? If yes, how?</p>
  
  <p><strong>Note</strong>: My question is different from <a href="https://stackoverflow.com/questions/11625673/sql-update-where-in-set-of-data">this</a>. As I want to update column values with array values, but not by single/static value.</p>
  
  <p><strong>This question is not related to coding, so please ignore for-loop syntax. It is related to SQL query optimization.</strong></p>