skip to Main Content

Let’s assume the table has 110 rows. The following skips the first 10 rows and returns the other 100:

SELECT ... FROM ... ORDER BY ... LIMIT 10, 100

Is there a way to replace 100 by whatever is left?

Desired pseudo-code:

SELECT ... FROM ... ORDER BY ... LIMIT 10, *

3

Answers


  1. SELECT * FROM TABLE_NAME LIMIT (SELECT count(*) FROM TABLE_NAME) OFFSET 10;
    

    Not sure about the execution time though.

    SELECT count(*) FROM TABLE_NAME
    

    This is returning the number of available rows

    Login or Signup to reply.
  2. SELECT Statement

    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:

    SELECT * FROM tbl LIMIT 95,18446744073709551615;

    Login or Signup to reply.
  3. Select * from (
    Select *,Row_Number() Over(Order By ID ASC) RN From Table 
    ) as vw
    where RN >10
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search