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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T04:05:26+00:00 2026-05-18T04:05:26+00:00

I currently have a query running on my site which looks for all rows

  • 0

I currently have a query running on my site which looks for all rows which don’t have a particular attribute. So although I have sequential numbers for the row numbers, the actual result will have gaps in the primary keys. Turns out this is difficult to explain, so I’ll try and add some code!

Here’s the WHERE part of my statement, the rest is unimportant:

...WHERE 
       thought_deleted = 0 
   AND 
       thought_ID <= (SELECT MAX(thought_ID) FROM rmt_thoughts ORDER BY thought_ID) - $start 
   ORDER BY 
       thought_date_created DESC 
   LIMIT $number

$number and $start are values passed to the query using PHP. The part I want to change is the AND part. Instead of looking for thought_ID values which are less than a particular ID, I want to select as if each thought_deleted = 0 row has a sequential ID. I hope this makes sense!

I’m assuming I need to either a) make some kind of alias which counts the number of rows, and sort by that or b) just do some sort of limit thingy which only looks at the values I want. Either way, I’ve been googling for a while I am pretty exhausted and stuck. Has anyone seen anything like this before?

Thanks guys 🙂

Sparkles*

  • 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-05-18T04:05:27+00:00Added an answer on May 18, 2026 at 4:05 am

    Apparently you want to do some kind of pagination.
    Simply specify an offset using LIMIT <offset>, <limit> instead of just LIMIT <limit>.

    For example, to retrieve rows 1..5 you use LIMIT 0, 5 and for the next 5 rows you use LIMIT 5, 5.

    In your case you probably want to use LIMIT $start, $number assuming $start is zero-based.

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

Sidebar

Related Questions

I currently have a query that looks like this: SELECT NON EMPTY ([Measures].[TOTAL]) ON
Dear all, I have a select query that currently produces the following results: DoctorName
I currently have the query running on Postgres: SELECT * FROM addenda.users WHERE users.username
I currently have a query similar to: SELECT users.fname, users.lname, sales.date FROM users LEFT
I currently have a SQL query that returns a number of fields. I need
I currently have a bunch of SQLCHAR objects from a database query. The query
I currently have a list of things to update in the given mysqli query:
I have a query that is currently using a correlated subquery to return the
Hey guys I have a query that currently finds the latest comment for each
I have a select query that currently produces the following results: Description Code Price

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.