

- 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
MySQL limit in a range fail to display first 3 row?
Following is the syntax to display only the first 3 rows with LIMIT set in a range −
select *from yourTableName limit yourStartIndex,yourEndIndex;
Let us first create a table −
mysql> create table demo67 −> ( −> id int, −> user_name varchar(40), −> user_country_name varchar(20) −> ); Query OK, 0 rows affected (0.72 sec)
Insert some records into the table with the help of insert command −
mysql> insert into demo67 values(10,'John','US'); Query OK, 1 row affected (0.19 sec) mysql> insert into demo67 values(1001,'David','AUS'); Query OK, 1 row affected (0.14 sec) mysql> insert into demo67 values(101,'Mike','UK'); Query OK, 1 row affected (0.09 sec) mysql> insert into demo67 values(102,'Carol','AUS'); Query OK, 1 row affected (0.11 sec) mysql> insert into demo67 values(110,'Chris','US'); Query OK, 1 row affected (0.36 sec) mysql> insert into demo67 values(105,'David','AUS'); Query OK, 1 row affected (0.08 sec)
Display records from the table using select statement −
mysql> select *from demo67;
This will produce the following output −
+------+-----------+-------------------+ | id | user_name | user_country_name | +------+-----------+-------------------+ | 10 | John | US | | 1001 | David | AUS | | 101 | Mike | UK | | 102 | Carol | AUS | | 110 | Chris | US | | 105 | David | AUS | +------+-----------+-------------------+ 6 rows in set (0.00 sec)
Here is the query for MySQL limit to display the first three rows −
mysql> select *from demo67 limit 0,3;
This will produce the following output −
+------+-----------+-------------------+ | id | user_name | user_country_name | +------+-----------+-------------------+ | 10 | John | US | | 1001 | David | AUS | | 101 | Mike | UK | +------+-----------+-------------------+ 3 rows in set (0.00 sec)
- Related Questions & Answers
- Display first selected row in MySQL?
- MySQL LIMIT to select a single row
- How to select first and last row record using LIMIT in MySQL?
- How to ORDER BY DESC and display the first 3 records in MySQL?
- Display 3 decimal places in MySQL?
- Display random row from a MySQL table
- How to use if clause in MySQL to display Students result as Pass or Fail in a new column?
- Difference between fail-fast and fail safe in Java
- How to display 3 random values from MySQL table?
- Ignore first 4 values in MongoDB documents and display the next 3?
- Counting pairs with range sum in a limit in JavaScript
- Get the first 10 rows followed by the syntax to display remaining row records with a single MySQL query
- Only display row with highest ID in MySQL
- How to select first and last data row from a MySQL result?
- Order by last 3 months first, then alphabetically in MySQL?
Advertisements