I have a query which goes like this:
INSERT INTO accounts(id, description, followers_count, friends_count, statuses_count)
VALUES(%s, %s, %s, %s, %s)
ON CONFLICT DO UPDATE
SET description=EXCLUDED.description,
followers_count=EXCLUDED.followers_count,
friends_count=EXCLUDED.friends_count,
statuses_count=EXCLUDED.statuses_count;
Now description, followers_count, friends_count, statuses_count
can all be NULL. My question is whether this query can be changed to only update when these values aren't NULL.
For example when:
description='joey tribbiani'
followers_count=45
friends_count=90
statuses_count=15
don't update with NULL values. But when it's the other way around, do the update.
You could use coalesce():