The difference between "select count (null)" and "select count (1)"

In MySQL

Select 1 from mytable

and

select null from mytable

both return the same number of rows. While it select count(1) from mytablereturns a string, it select count(null) from mytablealways returns 0. Why?

+3
source share
1 answer

COUNT returns the number of non-null values, so it returns 0 for null.

+6
source

Source: https://habr.com/ru/post/1739286/


All Articles