0

Getting this on postgres:

syntax error at or near ""user""

For the following:

insert into "user" ("id", "email") values ('1', '[email protected]') on conflict do update "user" set "id" = '1', "email" = '[email protected]'

Been playing with it for a while, not sure where the syntax error is. Thank you for your help.

1
  • @Lexib0y No, it shouldn’t. Commented Dec 16, 2017 at 22:03

2 Answers 2

2

Apparently, you can't specify the table name in the ON CONFLICT UPDATE SET clause. The following seems to work:

insert into "user" ("id", "email") values ('1', '[email protected]')
on conflict do update set "id" = '1', "email" = '[email protected]'

The syntax here:

....
DO UPDATE SET { column_name = { expression | DEFAULT } |
                ( column_name [, ...] ) = ( { expression | DEFAULT } [, ...] ) |
                ( column_name [, ...] ) = ( sub-SELECT )
              } [, ...]
          [ WHERE condition ]
Sign up to request clarification or add additional context in comments.

Comments

1

Remove the "user" after ON CONFLICT DO UPDATE.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.