Reputation: 3068
I have a table 'users
' with structure -
id int auto_increment primary key,
name varchar(25),
username varchar(25))
.
I have 20 records in it. I want to fetch all records in the range 5-10. How can I do that in 'MYSQL'?
I tried solutions that I saw on many websites but they didn't work for me. They showed errors while executing query. I tried this query too:
SELECT * FROM users offset 5 rows fetch next 5 rows only;
But it didn't work too. How can I achieve the desired result in 'MySql'?
Upvotes: 0
Views: 1066
Reputation: 803
Try this
SELECT column_name(s) FROM table_name LIMIT from, number;
Where number specified no. of records to be returned and from specified location from which record fetching will start.
SELECT * FROM users LIMIT 5, 5;
Upvotes: 2