Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个脚本,用户可以在其中跨多个表选择一个字段。它使用 aUnion来获取所有行。现在,我有一个映射数组来指示每个表中是否存在特定字段,如果不存在,它会用来"" as field_name检查所有内容。
Union
"" as field_name
我想知道是否有一种方法可以在查询中引用可能不存在的列,例如COALESCE如果该列不存在,而不是抛出错误,它只返回一个默认值。
COALESCE
coalesce 仍然需要一个字段名,所以它无济于事:
... COALESCE(non_existent_field, NULL)
由于字段不存在,仍然会导致错误。