Skip to content
Advertisement

selecting all rows except top row using offset in MySQL

How can I use offset clause to get all rows except the first row. I am using query like

SELECT * FROM EMPLOYEES ORDER BY SALARY OFFSET 1;

But this is not working in MySQL. what am I doing wrong here?

Advertisement

Answer

Sadly in MySQL OFFSET only works together with the LIMIT clause. So you need to use

SELECT * FROM EMPLOYEES ORDER BY SALARY LIMIT 18446744073709551615 OFFSET 1;

or

SELECT * FROM EMPLOYEES ORDER BY SALARY LIMIT 1, 18446744073709551615;

I have chosen that limit number from a different question

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement