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

  • Home
  • SEARCH
  • 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 9117815
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T04:59:09+00:00 2026-06-17T04:59:09+00:00

I’m a bit new to JOIN and I’m finding it difficult to understand how

  • 0

I’m a bit new to JOIN and I’m finding it difficult to understand how I can query one table with ORDER BY and LIMIT and using only ORDER BY on my JOINED ‘right’ table I think it is? So Basically if I was to query the two tables individually I would use these queries:

SELECT * FROM posts ORDER BY dateSubmitted DESC LIMIT ?,5 

‘?’ standing for my bind_param() because I’m creating a pagination. Now for my ‘right’ Second table:

SELECT * FROM postcomments WHERE postcomments.postID = posts.ID ORDER BY dateSubmitted DESC

As far as my understanding goes to ‘link’ the two tables together I want to be using LEFT JOIN so that I will receive all my data from the ‘left’ table (being posts).

SELECT * FROM posts LEFT JOIN postcomments ON postcomments.postID = posts.ID

Now I can do this but I’m unsure where I would but my ORDER BY and LIMIT for both tables?
I’ve seen several different ways and I think this is what’s getting me confused like I’ve seen this:

SELECT p.* FROM posts p ORDER BY posts.dateSubmitted DESC LIMIT ?,5 
LEFT JOIN (SELECT * FROM postcomments 
WHERE postscomments.postID = p.ID ORDER BY postcomments.dateSubmitted);

But I’m really unsure how to structure my query :S Any help appreciated 🙂

  • 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-17T04:59:10+00:00Added an answer on June 17, 2026 at 4:59 am

    It will be at the end like this:

    Select * from
    (SELECT * FROM posts  ORDER BY dateSubmitted DESC LIMIT ?,5) as tempPost
    LEFT JOIN postcomments on (postscomments.postID = tempPost.ID)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using the SimpleRSS gem to parse a WordPress RSS feed. The only
I want use html5's new tag to play a wav file (currently only supported
I'm making a simple page using Google Maps API 3. My first. One marker
I am reading a book about Javascript and jQuery and using one of the
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am trying to understand how to use SyndicationItem to display feed which is
I have a jquery bug and I've been looking for hours now, I can't
I am using JSon response to parse title,date content and thumbnail images and place
I am trying to find ID3V2 tags from MP3 file using jid3lib in Java.

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.