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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T11:44:58+00:00 2026-06-14T11:44:58+00:00

Imagine i had a set of 30 records for instance users : {user_id, name,

  • 0

Imagine i had a set of 30 records
for instance

users : {user_id, name, category}

and i did this Query:

     SELECT name
     FROM users
     WHERE category = "Student"
     AND id < 30
     ORDER BY user_id
     LIMIT 5

This would give me the users that have id from 1 to 5
but how about if i wanted to get the highest id values that are less than 30
in this case the desired results would be id’s from 24 -29.

ps. my real problem is a bit more complex than this, i just wanted get the basic theory.
also note that i would of used another AND clause to say > 23, but this wouldnt work with my schema.

  • 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-14T11:44:59+00:00Added an answer on June 14, 2026 at 11:44 am

    You could wrap what Dan J wrote into a set and SELECT from it, then applying an ASC order. Not sure of the MySQL syntax, but in MS SQL it would be:

    SELECT * FROM
       (Dan J's code) a
    ORDER BY user_id [ASC]
    

    The ASC is optional.

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

Sidebar

Related Questions

Imagine I've got a database with lots of data, from which users can search.
I have used this query on many occasions and never had an issue. I
Imagine I had an id column and each of its rows contained a number.
imagine this html on a page <div id=hpl_content_wrap> <p class=foobar>this is one word and
Imagine I have following table: NAME DATE OTHER_CONTANT 'A' '2012-06-05' 'baz' 'A' '2012-06-04' 'bar'
Imagine a very big gwt project of application. This is just a some form
imagine that you had a task that finished in, say 10 seconds. Now, after
Imagine the following (simplified) database layout: We have many holiday records that relate to
Lets say I have this data set... var a = [5,6,7]; var b =
Imagine, for a moment <select> <option value=volvo>Volvo</option> <option value=saab>Saab</option> <option value=mercedes>Mercedes</option> <option value=audi>Audi</option> </select>

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.