我有一个"customer_config"
包含这些列的表:
company (varchar)
warehouse (numeric)
section (numeric)
config_keyword (varchar)
config_value (varchar)
Run Code Online (Sandbox Code Playgroud)
这两config_*
列可以应用于整个公司(warehouse
和section
为空)、公司内的整个仓库(section
为空)或仓库内的一个部分。
因此,我们可以为公司设置一个默认行,然后使用一个或多个行来覆盖特定仓库或仓库和部分的配置值。
我只想返回给定公司、仓库和部门的最具体的行。像这样的伪代码:
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)
Run Code Online (Sandbox Code Playgroud)
最具体的行应优先。
同一级别上可以有多个相同的条目config_keyword
。
是否也可以为单个关键字返回多行?