select row from table and substitute a field with one from another column if not null
- by EarthMind
I'm trying construct a PostgreSQL query that does the following but so far my efforts have been in vain.
Problem:
There are two tables: A and B. I'd like to select all columns from table A (having columns: id, name, description) and substitute the "A.name" column with the value of the column "B.title" from table B (having columns: id, table_A_id title, langcode) where B.table_A_id is 5 and B.langcode is "nl" (if there are any rows).
I've tried using a CASE and COALESCE() but failed due to my inexperience with both concepts.
Thanks in advance.