SQL - LIMIT query
ORDER BY EmployeeID
I want to select only 3 records that are the 5th, 6th and 7th records in a table called Employees. This Employees table consists of 100 records.
I tried using "LIMIT" function as stated in the code but it was not working - I do not understand where have I gone wrong.
Thanks in advance for helping me out.
The syntax for MySQL's
LIMIT offset, count
offsetmeans the number of records from the top which you want to skip completely, and
countis the total number of records to be returned.
So if you want 3 records starting from the 5th position, then use this query:
SELECT * FROM Employees ORDER BY EmployeeID LIMIT 4, 3;
You can try this one
SELECT * FROM employees LIMIT 5, 3;
and also query below can be help you
SELECT * FROM employees WHERE id BETWEEN value1 AND value2;