动态SQL查询基于单元格中的空值忽略空值 [英] Dynamic SQL Query to ignore null values based on null value in cell
问题描述
我在运行时有一个动态SQL查询,其中具有不同的列名和表.
I have a dynamic SQL query with different column names and tables at runtime.
我希望基于行是否在任何单元格中包含Null值的情况下,使SQL查询忽略读取数据.
I am looking to get the SQL query to ignore reading data based on if a row contains Null value in any cell.
SELECT rsv_intension_rsvt
FROM resolve_table_kb
where rsv_intension_rsvt is not null;
我知道使用IS NOT NULL
.
但是问题是我不知道查询语法(即列名,以便可以使用IS NOT NULL
).
But the problem is that I wouldn't know the query syntax (i.e. columns name so that IS NOT NULL
can be used).
是否有可用于SQL查询读/收集行仅当所选择的行中的所有细胞是NOT NULL一个动态的解决方案.
Is there a dynamic solution that can be used for the SQL query to read/collect rows only when all cells in a selected row are NOT NULL.
谢谢
推荐答案
否,没有select where * is not null
类型的查询.您必须分别测试每个字段:
No, there's no select where * is not null
-type query. You have to test every field individually:
SELECT ...
FROM ...
WHERE field1 is not null AND field2 is not null AND .... AND fieldN is not null
也许可以尝试COALESCE()
操作,但这仍然很丑陋:
You could try a COALESCE()
operation, perhaps, but that's still ugly:
WHERE COALESCE(field1, field2, ..., fieldN, 'allarenull') <> 'allarenull'
但是您仍然必须列出表中的所有字段.
but then you STILL have to list all of the fields in the table.
这篇关于动态SQL查询基于单元格中的空值忽略空值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!