Answer the question
In order to leave comments, you need to log in
How to use WHERE on specific column in DO UPDATE?
Good afternoon.
I have this Frankenstein
INSERT
INTO usersdata_mirror
(user_id, domain, name, in_chats)
VALUES
(100, 'username', 'First name', ARRAY[group_id])
ON CONFLICT
(user_id)
DO UPDATE
SET
name = excluded.name,
domain = excluded.domain,
in_chats = usersdata_mirror.in_chats || ARRAY[group_id]::int[]
WHERE
not(usersdata_mirror.in_chats @> ARRAY[group_id]::int[])
Answer the question
In order to leave comments, you need to log in
Your alignment of request confuses you.
UPDATE tablename
SET
name = ?,
domain = ?,
in_chats = usersdata_mirror.in_chats || ARRAY[?]::int[]
WHERE
not(usersdata_mirror.in_chats @> ARRAY[?]::int[]) and user_id = ?
in_chats = case when ... then ... else usersdata_mirror.in_chats end
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question