title: SQL query for insert into with update on duplicate key is error
body: <p>I got error on the following query</p>
  
  <pre><code>INSERT INTO tableName3 (column1, column2)
      SELECT 
          b.column1,
          SUM (a.column2) AS SumColumn2
      FROM 
          tableName1 AS a
      JOIN 
          tableName2 AS b ON a.column1 = b.column2 
      GROUP BY 
          b.column2
  ON DUPLICATE KEY UPDATE tableName3
     SET column2 = SUM (a.column2) AS SumColumn2
  </code></pre>
  
  <p>The error messages are </p>
  
  <blockquote>
    <p>Incorrect syntax near the keyword 'ON*'</p>
  </blockquote>
  
  <p>and </p>
  
  <blockquote>
    <p>Incorrect syntax near the keyword 'AS'</p>
  </blockquote>
  
  <p>How to fix it?</p>