MySQL LIMIT Clause
The LIMIT clause is used to specify the number of records to return.
The LIMIT clause is useful on large tables with thousands of records. Returning a large number of records can impact performance.
LIMIT Syntax
SELECT column_name(s)
FROM table_name
WHERE condition
LIMIT number;
Demo Database
Below is a selection from the “Employees” table in the sample database:
MySQL LIMIT Examples
The following SQL statement selects the first three records from the “Employees” table:
Example
SELECT * FROM Employees
LIMIT 3;
ADD a WHERE CLAUSE
The following SQL statement selects the first three records from the “Employeess” table, where the City is “London”:
Example
select * from Employees
where City = 'London'
LIMIT 3;
No comments:
Post a Comment