MySQL : About LIMIT 0 , 30

Limit is used to limit your MySQL query results to those that fall within a specified range. You can use it to show the first X number of results, or to show a range from X - Y results. It is phrased as Limit X, Y and included at the end of your query.
X is the starting point (remember the first record is 0) and Y is the duration (how many records to display).

Table 'example' have following data.
SELECT * FROM `example` ORDER BY `example`.`age` ASC LIMIT 0 , 30
id name age
3 Amit 26
5 pani 27
2 Sanjay 28
4 Lucky 29
6 atul 30
1 Kumar 31

SELECT * FROM `example` ORDER BY `example`.`age` ASC LIMIT 3 , 1

id name age

4 Lucky 29
This will show records 3rd only (remember the first record is 0)

Comments

CodeSumWaza said…
cool. Nice and simple. Like it.

Popular posts from this blog

How do I Use the Linux Top Command?

IOPS measurement