Tutorial :how can i limit the selection in MySQL?


I am confuse on how to limit selection in MySQL (e.g SELECT * FROM tblProduction LIMIT 1,N;) where N is unknown.. Can anyone help me on how can I limit the selection in MySQL? I want to show the records starting from row 2 (two) up to the end of the records. Thanks!


This is from the LIMIT documentation:

To retrieve all rows from a certain offset up to the end of the result set, you can use some large number for the second parameter. This statement retrieves all rows from the 96th row to the last:

SELECT * FROM tbl LIMIT 95,18446744073709551615;  

EDIT: So in your case you would just change 95 to 2. Then you would get all rows starting from the 2 result.


Hi you can either pass the N value by Query string or some cookie.

"SELECT * FROM tblProduction LIMIT 1,".$_GET[Limit];  

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »