- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Get the first 10 rows followed by the syntax to display remaining row records with a single MySQL query
Let us first create a table −
mysql> create table DemoTable ( Id int ); Query OK, 0 rows affected (0.71 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values(100); Query OK, 1 row affected (0.31 sec) mysql> insert into DemoTable values(101); Query OK, 1 row affected (0.26 sec) mysql> insert into DemoTable values(102); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable values(103); Query OK, 1 row affected (0.64 sec) mysql> insert into DemoTable values(104); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable values(105); Query OK, 1 row affected (0.08 sec) mysql> insert into DemoTable values(106); Query OK, 1 row affected (0.25 sec) mysql> insert into DemoTable values(107); Query OK, 1 row affected (0.44 sec) mysql> insert into DemoTable values(108); Query OK, 1 row affected (0.62 sec) mysql> insert into DemoTable values(109); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable values(110); Query OK, 1 row affected (0.31 sec) mysql> insert into DemoTable values(111); Query OK, 1 row affected (0.94 sec) mysql> insert into DemoTable values(112); Query OK, 1 row affected (0.08 sec) mysql> insert into DemoTable values(113); Query OK, 1 row affected (0.35 sec) mysql> insert into DemoTable values(114); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values(115); Query OK, 1 row affected (0.25 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+------+ | Id | +------+ | 100 | | 101 | | 102 | | 103 | | 104 | | 105 | | 106 | | 107 | | 108 | | 109 | | 110 | | 111 | | 112 | | 113 | | 114 | | 115 | +------+ 16 rows in set (0.00 sec)
Following is the query to get the first 10 rows followed by the remaining rows −
mysql> select *from DemoTable LIMIT 999 offset 0;
This will produce the following output −
+------+ | Id | +------+ | 100 | | 101 | | 102 | | 103 | | 104 | | 105 | | 106 | | 107 | | 108 | | 109 | | 110 | | 111 | | 112 | | 113 | | 114 | | 115 | +------+ 16 rows in set (0.00 sec)
- Related Articles
- Get values from all rows and display it a single row separated by comma with MySQL
- MySQL query to display only the records that contains single word?
- MySQL query to get a specific row from rows
- MySQL query to concatenate records with similar corresponding ids in a single row separated by a special character
- How to get multiple rows in a single MySQL query?
- Count multiple rows and display the result in different columns (and a single row) with MySQL
- A single MySQL query to combine strings from many rows into a single row and display the corresponding User Id sum in another column?
- How to write a MySQL query to select first 10 records?
- MySQL query to display the count of distinct records from a column with duplicate records
- MySQL query to display records ordered by numeric difference?
- MySQL query to select rows except first row in descending order?
- MySQL query to subtract date records with week day and display the weekday with records
- Insert all the values in a table with a single MySQL query separating records by comma
- Can we get records “Jone Deo” or “Deo Jone” with a single MySQL query?
- Comparing two columns in a single MySQL query to get one row?

Advertisements