views:

39

answers:

1

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?

+3  A: 

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;
Paul Dixon