I've got (key, value)
pairs stored in two different tables - company_settings
and branch_settings
. A key
can exist in none, one or both of the tables.
In case the key
exists in both tables, I'd like to use the value
stored in the branch_settings
table. Otherwise, if available, I'd like to fall back to the value
stored in the company_settings
table.
company_settings
-------------------------
| key | value
-------------------------
| key.A | 4 |
-------------------------
| key.B | 5 |
-------------------------
branch_settings
-------------------------
| key | value
-------------------------
| key.A | 1 |
-------------------------
So, if I query for key.A
the result should be 1
since key.A
exists in both tables and I want to give higher precedence to records from branch_settings
table.
If I query for key.B
the result should be 5
since key.B
exists only in company_settings
table.