title: mysql insert from one table to another based on select
body: <p>Supposing we have</p>
  <p>Table A</p>
  <pre><code>field 1 | field 2
  
  orange  | fruit
  apple   | fruit
  </code></pre>
  <p>and</p>
  <p>Table B</p>
  <pre><code>field 1 | field 2
  
  orange  | fruit
  lemon   | fruit 
  </code></pre>
  <p>And want to insert only the rows from Table B to Table A that don't match on field 1 so that Table A becomes:</p>
  <p>Table A</p>
  <pre><code>field1  | field2
  
  orange  | fruit
  apple   | fruit
  lemon   | fruit
  </code></pre>
  <p>Ive tried</p>
  <pre><code>insert into tableA (field1, field2)
  select field1, field2 from tableB
  where not exists 
  (select * from tableA as a join tableB as b on a.field1 = b.field1)
  </code></pre>
  <p>(no insert)</p>
  <p>and</p>
  <pre><code>insert into tableA (field1, field2)
  select field1, field2  from tableA as a left join tableB as b on a.field1 = b.field1  
  union 
  select field1, field2  from tableA as s right join tableB as b on a.field1 = b.field1 
  where a.field1 != b.field1
  </code></pre>
  <p>(incorrect insert)</p>