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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T12:56:32+00:00 2026-06-15T12:56:32+00:00

Is it possible to select just 2 questions per status. I know mysql doesn’t

  • 0

Is it possible to select just 2 questions per status. I know mysql doesn’t support limits for subqueries but I’ve seen workarounds which I can’t figure out how to use for this query. Is this a one query problem or do I have to use extra queries? I’m trying to select 2 rows for each status.

Without LIMIT 2 the following query will work, but it has too many results hence the need to limit it.

SELECT id FROM questions WHERE status_id = c.status_id LIMIT 2

Query:

  ...
    FROM questions q, users u, users lu, tags t, question_tags tt, connection c
   WHERE q.user_id = u.id
     AND tt.tag_id = t.id
     AND tt.question_id = q.id
     AND c.user_id = 100
     AND q.last_user = lu.id
     AND q.id IN (SELECT id FROM questions WHERE status_id = c.status_id LIMIT 2)
GROUP BY q.id
ORDER BY q.date DESC
  • 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-15T12:56:33+00:00Added an answer on June 15, 2026 at 12:56 pm
    ...
        FROM questions q, users u, users lu, tags t, question_tags tt, connection c
       WHERE q.user_id = u.id
         AND tt.tag_id = t.id
         AND tt.question_id = q.id
         AND c.user_id = 100
         AND q.last_user = lu.id
         AND q.id IN (SELECT MAX(id) FROM questions WHERE status_id = c.status_id, 
                      SELECT MAX(id) FROM questions WHERE status_id = c.status_id AND id < 
                            (SELECT MAX(id) FROM questions WHERE status_id = c.status_id))
    GROUP BY q.id
    ORDER BY q.date DESC
    

    Ugly, I know, but it should work.

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

Sidebar

Related Questions

In a MySql select statement involving aggregation, is it possible to select just the
Is it possible to select records in a mysql database that does not start
I know there's similar questions but none seem to apply as to what I
I know this is possible I just dont know how to the code or
I've seen a few similar questions to this one, but none that were quite
can anybody post the simplest possible example for django-ajax-selects ? Just one model with
Possible Duplicate: Select xml node by attribute in php Is there any function like
Is it possible to select and delete at the same time? eg: in one
It is possible to select a different dataset (query) depending on the value of
Is it possible to select within a select (chaining) with my jQuery? I basically

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.