Here is my query
$getPosts = mysql_query ('SELECT `posts`.*, COUNT(`comments`.`comment_id`)
FROM `posts`
LEFT JOIN `comments`
ON (`posts`.`post_id` = `comments`.`post_id`)
ORDER BY `posts`.`post_id` DESC')
or die(mysql_error());
and then to loop through it...
while ($post = mysql_fetch_row($getPosts))
{
echo $post[1] . ' ' . $post[4] . ' comments'; // example
}
it all works fine, but only for the first row.
now, post_id 1 has 2 comments. post_id 2 has no comments in the DB.
I assume this is how JOIN works, but I don't understand. I think LEFT JOIN only matches what's on the left (so post_id) but I tried INNER JOIN, OUTER JOIN, etc.. and it doesn't work