[英]Finding all NULL values from a table
I am using mySQL (php) and trying to find all the rows in an entire table, including null values. 我正在使用mySQL(php)并尝试查找整个表中的所有行,包括空值。 Right now I am SELECT COUNT(*) FROM orders, which does not include the NULL.
现在,我是SELECT COUNT(*)FROM订单,其中不包含NULL。 I am confused on what to do next, I was thinking finding the NULL values seperately and then joining the two or something.
我对下一步做什么感到困惑,我想分别查找NULL值,然后将两者结合在一起。 However I cannot find the NULL for o_order-priority php tops reading it at 'order'...what do i do?
但是我找不到在'order'读取o_order-priority php顶部的NULL ...我该怎么办? There are 9 columns under the orders table.
订单表下有9列。
Instead of count(*) use the column name like 代替count(*)使用列名,例如
Select count('name') from table
this will count all the rows whether null or with data 这将计算所有行是否为null或包含数据
If your table has 3 rows. 如果您的表有3行。 A select count( ) --> 3 rows.
选择count( )-> 3行。 I think that you should try to count if a column of this table has a null value.
我认为您应该尝试计算此表的列是否为空值。 If you have a column named "order_text" and want to count the number of null value you can use: Select count( ) from orders where order_text is null;
如果您有一列名为“ order_text”的列,并且想要计算空值的数量,则可以使用:从order_text为null的订单中选择count( );
COUNT(*)
will return all count of rows including null
COUNT(*)
将返回所有行数,包括null
see this example 看这个例子
Declare @percapHistPrev table
(
id int
)
insert into @percapHistPrev
select 1 union all
select null
select COUNT(*) from @percapHistPrev
OUTPUT 输出值
id
2
select COUNT(id) from @percapHistPrev
id
1
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.