Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
MySQL SELECT to skip first N results?\\n
To skip records in MySQL SELECT, use OFFSET. Let us first create a table−
mysql> create table DemoTable ( Name varchar(40) ); Query OK, 0 rows affected (0.63 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values('Chris');
Query OK, 1 row affected (0.22 sec)
mysql> insert into DemoTable values('Robert');
Query OK, 1 row affected (0.13 sec)
mysql> insert into DemoTable values('Mike');
Query OK, 1 row affected (0.18 sec)
mysql> insert into DemoTable values('Bob');
Query OK, 1 row affected (0.17 sec)
mysql> insert into DemoTable values('David');
Query OK, 1 row affected (0.11 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+--------+ | Name | +--------+ | Chris | | Robert | | Mike | | Bob | | David | +--------+ 5 rows in set (0.00 sec)
Following is the query to skip first N results −
mysql> select *from DemoTable LIMIT 100 offset 3;
This will produce the following output −
+-------+ | Name | +-------+ | Bob | | David | +-------+ 2 rows in set (0.00 sec)
Advertisements
