I would like to make an update to a table, and the columns updated is dependent on a condition. I already know how to make a conditional WHERE clause like so:
UPDATE table SET colA='apple', colB='banana' WHERE colC='fruits
However I would like to base the update on a condition, such that if the conditional is false, only colA will update. Something to the extent of the following:
UPDATE table SET colA='apple', (if $1=true colB='banana') WHERE colC='fruits
The only resources I'm finding are pertaining to the first example. Is this possible in Postgres? I would like to avoid making separate queries for this type of condition.