假设我有一个表“interesting_table”,我想在其中找到所有条目都不为空的所有行。
我在努力
select * from interesting_table where * is not NULL ;
它不起作用,因为 * 未被识别为列。如何在不列出所有列的情况下修改它?
最佳答案
两种选择:
1) 使用类似 CONCAT
的函数,如果任何参数为 null,该函数将返回 null
select *
from interesting_table
where concat(data1, data2) is not null;
2) 对同一个表使用NATURAL JOIN
。如果任何列为 NULL,则该行的 JOIN 将失败。
select t1.*
from interesting_table t1
natural join interesting_table t2;
如果表包含重复项,您可能需要使用 DISTINCT。
关于mysql - SQL 查询 - 查找所有条目均为非 Null 的行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42308627/