[Classic explanation] The difference between count(1), count(*), count(x)

1.count(*)

   count(*) is to count the number of rows in the entire table.

   A table has multiple rows, as long as one field in each row is not empty, this row will be counted.

2.count(1)

  count(1) also counts the rows of the entire table.

  Here is the number of 1s marked on the left

3.count(x)

  count(x) is also to calculate the rows of the entire table. 

count(x), the x here is a mark count, it can be 2, 3, that is, the number of 2, 3 is calculated, and the sum of the numbers is the total number of rows in the table.

 

Guess you like

Origin blog.csdn.net/Sunshineoe/article/details/111769585