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:
What I've seen you can do is:
insert into tab(id, val) values(1, 'nosert'), (2,
'nosert'), (3, 'nosert') on duplicate key ignore returning id;
Why can't I do something like this?
insert into table_one (field_one, field_two) select field_one, field_two from table_two on duplicate key ignore returning field_one;
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 on duplicate key ignore returning field_one
.
Is this not possible with select from
?