title: MERGE syntax used to UPSERT or INSERT on duplicate UPDATE
body: <p>So I'm coming from MySQL where I could do <a href="http://dev.mysql.com/doc/refman/5.0/en/insert-on-duplicate.html" rel="nofollow noreferrer">INSERT on DUPLICATE UPDATE</a>:</p>
  
  <pre><code>INSERT INTO table (a,b,c) 
  VALUES (1,2,3)
  ON DUPLICATE KEY UPDATE c=c+1;
  </code></pre>
  
  <p>But now I'm using PostgreSQL and there are efforts to add the UPSERT functionality, looks like MERGE might work for what I would like but wanted to see if this is the most optimal syntax. <a href="http://archives.postgresql.org/pgsql-hackers/2008-04/msg01157.php" rel="nofollow noreferrer">Example Syntax 1</a>, <a href="https://stackoverflow.com/questions/1109061/insert-on-duplicate-update-postgresql">I've also seen this but don't understand how to implement</a>. I haven't tried this yet because I thought MERGE was used for merging data from table1 to Table2 or would something like this work?</p>
  
  <pre><code>MERGE
  INTO    table
  USING   table
  ON      c = 1
  WHEN MATCHED THEN
  UPDATE
  SET     c=c+1
  WHEN NOT MATCHED THEN
  INSERT  (a,b,c)
  VALUES  (1,2,3)
  </code></pre>
  
  <p>Any other suggestions? </p>