Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7060431
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:21:08+00:00 2026-05-28T04:21:08+00:00

I think I have reached my current limits with Left Joins. Currently I have

  • 0

I think I have reached my current limits with Left Joins. Currently I have the following MySQL query which is working fine:

SELECT blog.id, blog.title, blog.post, blog.date, blog.time,
       count(blog_comment.b_id) CommCount
FROM blog 
LEFT JOIN blog_comment ON blog.id = blog_comment.b_id
GROUP BY blog.id
ORDER BY id DESC
LIMIT $start_blog, $blog_per_page

This will display a list of blog posts and display the number of comments each post has, nice and simple.

For the admin panel I want to display the Blog Posts followed by the number of comments on each post and then a new field which displays the number of pending comments.

The pending comments are stored in blog_comment.pending (1 for pending, 0 for not pending)

I just can’t seem to get my head around how to do it.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T04:21:08+00:00Added an answer on May 28, 2026 at 4:21 am

    Try this:

    SELECT blog.id, blog.title, blog.post, blog.date, blog.time, 
           count(blog_comment.b_id) CommCount,
           sum(blog_comment.pending) PendingComments
    FROM blog 
    LEFT JOIN blog_comment ON blog.id = blog_comment.b_id 
    GROUP by blog.id 
    ORDER BY id DESC LIMIT $start_blog , $blog_per_page
    

    Sum will simply add up the number of pending flags…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I think I have this working but I need advice. I'd like to know
Currently in our enterprise we have a situation that i think it's not very
I have the following question: I am working on a JQuery script that turns
I have been following the salesforce Recruiting App tutorial, and reached the section on
I've been working on a problem for several weeks and have reached a point
I think I have a synchronization problem...It may be too basic..Please help.. I have
I think I have a problem in understanding the proper way of using MVC.
I think I have a basic understanding of REST, but something I'm stuck on
I think I have a conceptual misunderstanding and would appreciate an explanation. Within a
I think i have a basic problem in understanding the dojo toolkit. Well I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.