MySQL Tutorial – Limiting Data Retrieval

Limiting Data Retrieval

The LIMIT clause is used to limit the records to be displayed in the result set.

The syntax of LIMIT clause:

SELECT column_name(s)
FROM table_name
LIMIT startingROW, valueToExtract;

Let’s see some example:

Here is our database table: (employee_record)

[TABLE=3]

We want to display 3 records of employee starting from first row. To do that, issue the command:

SELECT id,f_name,l_name
FROM employee_record
LIMIT 0,3;

Result:

+----+------------+---------+
| id | f_name     | l_name  |
+----+------------+---------+
|  1 | Piolo      | Pascual |
|  2 | Sam        | Milby   |
|  3 | John Lloyd | Cruz    |
+----+------------+---------+
3 rows in set (0.00 sec)
, , ,

Post navigation

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.