The LIMIT clause limits the number of data records that are displayed in the result set of a search query. It contains the following properties:
- OFFSET: OFFSET defines the starting index of the result, i.e., the first record’s position that will be displayed in the result.
- VALUE: VALUE defines the number of records to be retrieved from the starting index, i.e., the OFFSET.
The LIMIT clause identifies the OFFSET index and then displays the number of records as specified in the VALUE from the OFFSET index. You can also just specify the value without specifying the offset, when the starting index is the first record.
The LIMIT clause is only used when a specific number of records is to be displayed. It is used towards the end of the query after all the other clauses and statements.
The basic syntax for using the LIMIT clause with a SELECT statement is:
SELECT column_name(s) FROM parent_table_name LIMIT OFFSET, VALUE
To view a list of the movies from the Movies table consisting of up to three records from the second starting index execute the following query:
SELECT * FROM Movies LIMIT 1,3
It will generate the following output:
|2057||Ant-Man and the Wasp||2018-07-13||14:20:00||052|
|2058||Hotel Transylvania 3: Summer Vacation||2018-07-14||17:00:00||052|
Last Updated 2023-08-28 18:12:09 +0530 +0530
Send your feedback to us