Skip to content

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?

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