简体   繁体   中英

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. Right now I am SELECT COUNT(*) FROM orders, which does not include the NULL. I am confused on what to do next, I was thinking finding the NULL values seperately and then joining the two or something. However I cannot find the NULL for o_order-priority php tops reading it at 'order'...what do i do? There are 9 columns under the orders table.

Instead of count(*) use the column name like

Select count('name') from table

this will count all the rows whether null or with data

If your table has 3 rows. A select count( ) --> 3 rows. 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;

COUNT(*) will return all count of rows including 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM