SQL 计算 NULL 单元格
我有以下问题。我在数据库中有一个表,有很多列。我可以执行不同类型的选择查询,例如,显示满足条件的每条记录:
- 名称以 _t0 结尾的列中的所有单元格
- 名称以 _t1 结尾的列中的所有单元格
- ...
获取列列表我使用信息模式形成查询。
现在,问题是:每个查询返回一条记录,其中包含大表列的子集。这意味着我可以获得一行(全部!)NULL。如何要求我的查询拒绝此类行,而不必明确输入列名(即通过说其中 col_1 不为空,col_2 不为空...)?是否可以?
提前致谢!!!
九月
I have the following problem. I have a table in a db, with many columns. I can do different kind of select queries, to show, for example, for each record that satisfies a condition:
- all cells from columns with names ending in _t0
- all cells from columns with names ending in _t1
- ...
To get the column lists to form the queries I use the information schema.
Now, the problem: each query returns a record with a subset of the columns of the big table. This means that I can get a row of (all!) NULLs. How can I ask my query to reject such rows without having to type in explicitely the column names (i.e. by saying where col_1 is not null, col_2 is not null...)? Is it possible?
Thanks in advance!!!
Sep
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我一直在寻找同样的东西,但我认为这是不可能的。
唯一合适的解决方案似乎是为它们命名,来自 Bytes.com:
当然,这并不有趣,所以我编写了一些动态 SQL 来为我做到这一点。不太优雅,但我不确定是否有更好的方法。
I've been looking for the same, and I don't think it's possible.
The only decent solution seems to be to name them, from Bytes.com:
Of course that's no fun, so I wrote some dynamic SQL to do this for me. Hardly elegant, but I'm not sure there's a better way.