1

I'm trying to insert or return id of existing value in case of uniqueness conflict (the data is already there).

I'm guessing it could be something like this, but can't quite get it to return the actual ID

INSERT INTO my_table (my_column) VALUES ('my value') 
ON CONFLICT DO NOTHING
RETURNING ID;

where my_column has a unique constraint.

Any ideas?

Joey Baruch
  • 4,180
  • 6
  • 34
  • 48

0 Answers0