DNB5brims
DNB5brims

Reputation: 30648

MySQL Question about limiting the result

I want to know how to limit the MySQL result. I can use "select * from students" to show all the students, but it is too many. I can add where condition, but it still many students after I use where to filter the result. Is it possible to return first 100 students, and order by first name. And next time, I want the first 101-200 ... ... instead of return all the result to me at once.

I know it can be done by programming, but I want to do it in SQL command, is it possible to do so? If not, any suggestions?

Upvotes: 0

Views: 66

Answers (1)

Paul Dixon
Paul Dixon

Reputation: 301085

Check out the LIMIT clause, e.g.

#get first 100 rows
SELECT foo FROM bar LIMIT 0,100;

#get next 100 rows
SELECT foo FROM bar LIMIT 100,100;

Upvotes: 3

Related Questions