gpt4 book ai didi

mysql - 如何在 SQL 中选择没有空值的行(在任何列中)?

转载 作者:行者123 更新时间:2023-12-05 01:07:41 24 4
gpt4 key购买 nike

我有一个名为 table1

的表

它有 100 列:{col1, col2, ...,col100}

我了解如何 SELECTnot 在特定列中包含空值,例如 col1:

SELECT *
FROM table1
WHERE col1 IS NOT NULL

How do I SELECT all rows that do not contain null values in any column

尝试

SELECT *
FROM table1
WHERE * IS NOT NULL

但这会在 MySQL(我正在使用)中返回错误

最佳答案

您需要明确列出每一列。我会推荐:

select t.*
from t
where col1 is not null and col2 is not null and . . .

有些人可能更喜欢更简洁(但速度较慢)的方法,例如:

where concat(col1, col2, col3, . . . ) is not null

这实际上并不是一种简单的表达方式,尽管您可以使用元数据表或电子表格来构造查询。

关于mysql - 如何在 SQL 中选择没有空值的行(在任何列中)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67076546/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com