count(*) and count(column_name), what’s the difference in mysql.
count(*) and count(column_name) , what’s the difference in mysql.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
COUNT(*)counts all rows in the result set (or group if using GROUP BY).COUNT(column_name)only counts those rows wherecolumn_nameis NOT NULL. This may be slower in some situations even if there are no NULL values because the value has to be checked (unless the column is not nullable).COUNT(1)is the same asCOUNT(*)since 1 can never be NULL.To see the difference in the results you can try this little experiment:
Result: