Hey, I wasn’t sure if this is a possibility. I’d like to INNER JOIN 2 tables so I created the following SQL Statement
[CODE]SELECT blogs.id, blogs.createddate, blogs.title, blogs.userid, COUNT(0) AS Expr1
FROM blogs INNER JOIN blogs_comments ON blogs_comments.blogid = blogs.id AND blogs.userid = CurrentUser
GROUP BY blogs.id, blogs.createddate, blogs.title, blogs.userid
Okay, now obviously it’ll only show blogs that have comments. I want to be able to show blogs that have 0 comments as well (that’s why I tried Count(0), I was hoping just maybe. Is there a way to do that in the SQL Statement? I know I could just make the first recordset just pull everything from the blogs table and filter by id and then use the following code in a repeat loop:
[code=php]<?php
$blogid = $row_myblogs[‘ID’];
$blogcount = mysql_num_rows(mysql_query(“SELECT * FROM blog_comments WHERE blogid = ‘%$blogid%'”));
?>
(I know the above script doesn’t have the right variables, I used it from an old site I built).
Basically I was wondering if I’m going about this with the second example a longer way, when I can just do it all in the SQL Statement, or am I just shooting for the stars?
Suggestions?