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

The Archive Base Latest Questions

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

I couldn’t find a way to do it and am not sure how to

  • 0

I couldn’t find a way to do it and am not sure how to search for this question, as all I’ve found were not exactly what I wanted and the answers not applicable.

I have a table with two fields (char and num), ‘num’ is unique but ‘char’ not, as in the example:

char | num
_________
a    | 2
b    | 1
c    | 3
c    | 4 <-- I am here
c    | 7
c    | 8
d    | 5
e    | 9
f    | 6

what I want is to fetch N rows beginning in the line marked with the table ordered by ‘char’.

I’m using

SELECT * FROM table WHERE char >= $current_char ORDER BY char,num LIMIT $N

but it doesn’t do what I want, as it starts from the row with char=’c’ and num=’3′.

EDIT: I will probably count and use xdazz’s answer because the code will be clearer, but it looks that I could do this other way:

SELECT * FROM table WHERE char > $current_char OR (char = $current_char AND num >= $current_num) ORDER BY char,num LIMIT $N

but it is not very pretty.

  • 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-15T22:49:33+00:00Added an answer on June 15, 2026 at 10:49 pm

    You marked <-- I am here means you know that is the forth record, so you could just do :

    SELECT * FROM table ORDER BY char,num LIMIT 4, $N
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Couldn't find a better way to phrase this question. Here's the deal: I have
Couldn't find anything on this with a Google Search. Does anyone know how to
Couldn't find an answer to this question. It must be obvious, but still. I
I couldn't find the answer to this question in SO. I'll try to explain.
I couldn't seem to find a similar question to this. I am currently looking
I couldn't find the answer to this in any other question. Suppose that I
Couldn't seem to find the answer to this question - what is the haml
Couldn't really find it, but probably it's me not knowing how to search properly
Couldn't find any answer to this problem, or not even any questions asked. So
couldn't find a similar topic but this may boil down to not knowing how

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.