title: How to copy an sql column based on foreign key?
body: <p>How do I run the following query</p>
  <pre><code>INSERT INTO table1
  SELECT sourceId
  FROM table2
  WHERE table2.id = table1.productId
  </code></pre>
  <p>given that table2 has an id column and a sourceId column (and few others) and table1 already contains productId and I want to copy the sourceId column into the table as well?</p>
  <p>The error message I'm getting with this query is simply &quot;Unknown column 'table1.productId' in where clause&quot;, but if I include table1.productId in the SELECT and table1 on the FROM row, I get the &quot;Column count doesn't match value count at row 1&quot; error.</p>
  <p>Any idea how to fix up the query?</p>