Jump to content

query not returning the right number


onedumbcoder

Recommended Posts

I am having problems if a join query. I am creating a forum.

 

I am trying to grab subjects from the table, but my work only retrieves only those subjects that have posted items in them.

 

can someone help me correct this so that it also grabs forums with no posts or replies?

 

 

$query = "SELECT
                          forum.name as a, 
		 COUNT(forum_post.id) as b,
                         COUNT(forum_reply.id) as c
							FROM
								(forum 
									LEFT JOIN
										forum_post
									ON
									 	forum_post.forum_id=forum.id)
							LEFT JOIN
								forum_reply
							ON
								forum_reply.post_id=forum_post.id										
							WHERE
								forum.owner_id='1'
								AND forum.forum_type='2'
							ORDER BY 
								forum.name";

Link to comment
https://forums.phpfreaks.com/topic/135593-query-not-returning-the-right-number/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.