What is the difference between using COUNT(*) and COUNT(column) in a MySQL query for counting posts in PHP?

When counting posts in a MySQL query in PHP, using COUNT(*) will count all rows in a table regardless of null values in the specified column, while using COUNT(column) will only count non-null values in that column. If you want to count all posts, including those with null values in the specified column, use COUNT(*). If you only want to count posts with non-null values in the specified column, use COUNT(column).

// Count all posts
$query = "SELECT COUNT(*) FROM posts";
$result = mysqli_query($connection, $query);
$row = mysqli_fetch_array($result);
$totalPosts = $row[0];

// Count posts with non-null values in a specific column
$query = "SELECT COUNT(column) FROM posts WHERE column IS NOT NULL";
$result = mysqli_query($connection, $query);
$row = mysqli_fetch_array($result);
$totalPosts = $row[0];