The LIMIT clause in MariaDB is used to limit the number of records returned by the SELECT statement.
Syntax:
SELECT column\_name(s)
FROM table\_name
WHERE condition
LIMIT number;
The following parameters are used in the LIMIT clause.
column\_name(s) – the names of the columns want to select.
table\_name – the name of the table where you want to retrieval the data.
condition – The selection conditions.
number – The number of records you want to get.
Example:
SELECT \*
FROM Employees
LIMIT 5;
This will return the first 5 records from the Employees table.
If you want to specify a specific range of records, you can use the LIMIT clause with two arguments like so:
SELECT \*
FROM Employees
LIMIT 5,10;
This will return records from 6 to 15 (5 is the starting index and 10 is the number of records) from the Employees table.
Note: The first record of the result in MariaDB has an index of 0, not 1.