MySQL COUNT(*) and COUNT(column or expression) — Differences

Josh Otwell
An Idea (by Ingenious Piece)
4 min readMar 15, 2021

--

I write a lot of blog posts about MySQL, PHP, and Back-end Web Development. I look at blogging as a personal growth diary of how far I have come, as well as how much further I have to go.

Programming is hard. Remembering everything about programming is even harder. I don’t believe there is one single person who can remember every detail about programming. If such a person exists, then good for you.

All that said, I am not such a person. I need help with remembering things. Therefore, blogging also serves my future self with little tidbits of informational reminders.

It is a fantastic feeling to Google something related to a programming issue, problem, or question you have, only to land on your own website! (Yay! I knew I would need that one day!)

Where is all this going, Josh?

Well, I sometimes forget there is a difference in counting the number of rows in a MySQL table versus counting the number of column values for those rows. Because, as you will see, there is a difference.

So this blog post is that informational resource to my future self and anyone else who can benefit from it as well…

Image by OpenClipart-Vectors from Pixabay

MySQL COUNT() Aggregate Function

--

--

Josh Otwell
An Idea (by Ingenious Piece)

SQL | PHP | Photography. Sign-up for my free developer newsletter, OpenLampTech, here: openlamptech.substack.com