
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to select next row pagination in MySQL?
For this, use the LIMIT concept. Let us create a table −
mysql> create table demo40 −> ( −> id int not null auto_increment primary key, −> name varchar(40) −> ); Query OK, 0 rows affected (1.73 sec)
Insert some records into the table with the help of insert command −
mysql> insert into demo40(name) values('Chris'); Query OK, 1 row affected (0.23 sec) mysql> insert into demo40(name) values('David'); Query OK, 1 row affected (0.12 sec) mysql> insert into demo40(name) values('Mike'); Query OK, 1 row affected (0.10 sec) mysql> insert into demo40(name) values('Sam'); Query OK, 1 row affected (0.19 sec) mysql> insert into demo40(name) values('Carol'); Query OK, 1 row affected (0.12 sec) mysql> insert into demo40(name) values('bob'); Query OK, 1 row affected (0.13 sec)
Display records from the table using select statement −
mysql> select *from demo40;
This will produce the following output −
+----+-------+ | id | name | +----+-------+ | 1 | Chris | | 2 | David | | 3 | Mike | | 4 | Sam | | 5 | Carol | | 6 | bob | +----+-------+ 6 rows in set (0.00 sec)
Following is the query to select next row pagination in MySQL −
mysql> select *from demo40 limit 4,2;
This will produce the following output −
+----+-------+ | id | name | +----+-------+ | 5 | Carol | | 6 | bob | +----+-------+ 2 rows in set (0.00 sec)
- Related Questions & Answers
- Select the next row after skipping every 2 rows in MySQL
- How to select last row in MySQL?
- Select a random row in MySQL
- MySQL LIMIT to select a single row
- MySQL query to select records approaching in next 12 hours?
- MySQL query to select one specific row and another random row?
- SELECT where row value contains string in MySQL?
- How to select first and last row record using LIMIT in MySQL?
- How to select row when column must satisfy multiple value in MySQL?
- MySQL query to select maximum and minimum salary row?
- MySQL query to generate row index (rank) in SELECT statement?
- How to select first and last data row from a MySQL result?
- Pagination using MySQL LIMIT, OFFSET?
- MySQL pagination without double-querying?
- Select random row that exists in a MySQL table?
Advertisements