Sobes.tech
Junior

What is the difference between COUNT(*) and COUNT(column_name)?

sobes.tech AI

Answer from AI

COUNT(*) counts all rows in the table, including rows where all field values are NULL.

COUNT(column_name) counts only those rows where the specified column_name is not NULL.

Example:

SELECT COUNT(*) FROM my_table; -- Returns the total number of rows

SELECT COUNT(some_column) FROM my_table; -- Returns the number of rows where some_column is not NULL