I have a table
"customer_config" with these columns:
company (varchar) warehouse (numeric) section (numeric) config_keyword (varchar) config_value (varchar)
config_* columns can apply to an entire company (
section are null), an entire warehouse within a company (
section is null), or a section within a warehouse.
So we could have a default row for the company, and then one or more rows that override a configuration value for a specific warehouse or warehouse & section.
I want to return only the most specific row for a given company, warehouse, and section. Something like this pseudocode:
results = select * from customer_config where (all match) if results empty results = select * from customer_config where (company_code and warehouse match) if results empty results = select * from customer_config where (company_code matches)
The most specific row shall take precedence.
There can be multiple entries for the same
config_keyword on the same level.
Is it also possible to return multiple rows for a single keyword?