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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T08:54:30+00:00 2026-05-15T08:54:30+00:00

I recently posted a question about getting last 3 results in table in the

  • 0

I recently posted a question about getting last 3 results in table in the correct order. I now want the get all comments apart from the last 3 in the correct order.

Here is my syntax;

SELECT *
FROM (SELECT * 
      FROM $table 
      ORDER BY ID DESC 
      OFFSET 3) AS T 
ORDER BY TIME_STAMP

The error I am receiving is:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘OFFSET, 3) AS T ORDER BY TIME_STAMP’ at line 1

I can’t seem to get it to work. Any help much 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-05-15T08:54:31+00:00Added an answer on May 15, 2026 at 8:54 am

    According to the MySQL Documentation:

    To retrieve all rows from a certain
    offset up to the end of the result
    set, you can use some large number for
    the second parameter. This statement
    retrieves all rows from the 96th row
    to the last:

    They recommend you use a query such as:

    SELECT * FROM tbl LIMIT 95,18446744073709551615;
    

    So in your case, you should try:

    SELECT *
    FROM (SELECT * 
          FROM $table 
          ORDER BY ID DESC 
          LIMIT 3,18446744073709551615) AS T 
    ORDER BY TIME_STAMP
    

    Note that you can also use the PostgreSQL compatible version using the keyword OFFSET:

    SELECT *
    FROM (SELECT * 
          FROM $table 
          ORDER BY ID DESC 
          LIMIT 18446744073709551615 OFFSET 3) AS T 
    ORDER BY TIME_STAMP
    

    Just in case you are wondering, 18446744073709551615 = 2^64 - 1.

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

Sidebar

Related Questions

I recently posted a question about Azure... is it really an OS? I understand
I recently posted this question about codes for a gift-card-like voucher that users can
I recently posted a question about centering a page with CSS. I figured out
I recently posted a question about optimizing the algorithm to compute the Levenshtein Distance,
Recently I posted a question about the html helper dropdownlist and got it working
Recently i posted a question about what the variable is of a file which
Is there an easy way to sort sphinx results? Recently posted (by dates) Highest
Steve Yegge recently posted an interesting blog post on what he calls the universal
Recently Jeff has posted regarding his trouble with database deadlocks related to reading. Multiversion
I recently seen a flash game application that posted a score to a db

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.