title: insert select from on duplicate key ignore postgres
body: <p>I've read from this source that you can do an insert on dupcliate key ignore in postgres, but I cannot seem to get this to work for a select from:</p>
  
  <p><a href="https://www.postgresql.org/message-id/CAM3SWZRg4VcLCKprVEyuLHoXwUefuiz1-P69YLye8qktZb_%3DUQ@mail.gmail.com" rel="noreferrer">link</a></p>
  
  <p>What I've seen you can do is:</p>
  
  <pre><code>insert into tab(id, val) values(1, 'nosert'), (2,
  'nosert'), (3, 'nosert') on duplicate key ignore returning id;
  </code></pre>
  
  <p>Why can't I do something like this?</p>
  
  <pre><code>insert into table_one (field_one, field_two) select field_one, field_two from table_two on duplicate key ignore returning field_one;
  </code></pre>
  
  <p>I'm being told that I have syntax error near duplicate, but the query before then runs fine (although it colides on a duplicate index) and the rest of the query just adds the <code>on duplicate key ignore returning field_one</code>.</p>
  
  <p>Is this not possible with <code>select from</code>?</p>