Python MariaDB – Limit Clause using PyMySQL
The Limit clause is used in SQL to control or limit the number of records in the result set returned from the query generated. By default, SQL gives out the required number of records starting from the top but it allows the use of the OFFSET keyword. OFFSET allows you to start from a custom row and get the required number of result rows.
SELECT * FROM tablename LIMIT limit; SELECT * FROM tablename LIMIT limit OFFSET offset;
The following programs will help you understand this better.
Database in use:
Example 1: program to display only 2 records
Example 2: program to start from the second record and display the first two records