Search code examples
excelvbaqsqlquery

How to skip the first row of data in SQL Query?


I have this code:

select DOLFUT from [DATABASE $]

How do I get it to get data from the 2nd line? (skip only the first line of data and collect all the rest)


Solution

  • You can use LIMIT to skip any number of row you want. Something like

    SELECT * FROM table
    LIMIT 1 OFFSET 10
    
    SELECT * FROM tbl LIMIT 5,10;  # Retrieve rows 6-15
    

    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;
    

    With one argument, the value specifies the number of rows to return from the beginning of the result set:

    SELECT * FROM tbl LIMIT 5;     # Retrieve first 5 rows
    

    MySql docs