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 8345245
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T06:37:09+00:00 2026-06-09T06:37:09+00:00

i have a commenting system; I have one query SELECT ShoutID,Message, User, Date, ShoutImageThumb,

  • 0

i have a commenting system;
I have one query

SELECT ShoutID,Message, User, Date, ShoutImageThumb, ShoutImageBig,UserID, 
       Email, FullName, UserImageThumb, Admin FROM shoutbox LEFT JOIN users ON 
       users.Email = shoutbox.User ORDER BY ShoutID DESC LIMIT 10

and while its going through the loop on the page
i run another query in the loop to get the comments for that message

SELECT users.UserID, users.Email, users.FullName, shoutboxcomments.ShoutID, 
       shoutboxcomments.`Comment`, shoutboxcomments.`Date`, 
       shoutboxcomments.`User`, shoutboxcomments.CommentID FROM shoutboxcomments 
       LEFT JOIN users ON users.Email = shoutboxcomments.User 
       WHERE ShoutID = '.$ShoutID.' ORDER BY CommentID ASC

is it possible to join these queries or how i can streamline it , as im building in php using mvc architecture

  • 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-06-09T06:37:10+00:00Added an answer on June 9, 2026 at 6:37 am

    Instead of running one query per post, use IN to get the comments for multiple posts at once.

    SELECT users.UserID, users.Email, ...
    FROM shoutboxcomments
    LEFT JOIN users
    ON users.Email = shoutboxcomments.User
    WHERE ShoutID IN (1, 4, 15, 22)
    ORDER BY CommentID
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a PHP script that very much like a commenting system, but requires
I have JavaScript for a commenting system, however when I click on the submit
We have a commenting system built into our engine that allows programmers to put
I´m struggling with comments. I have a site that has a commenting system, and
I'm working on a commenting system that uses Markdown and I want to have
I have tweets and commenting system like this This is the code block for
I have a requirement to add commenting system to a page (similar to 'Post
I have made an application recently which has articles, etc, with a commenting/moderation system
I have a commenting system so when the submit button is pressed It sends
I have a page and I am trying to add an ajax commenting system

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.