
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
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 Articles
- Display first selected row in MySQL?
- How to select first and last row record using LIMIT in MySQL?
- MySQL LIMIT to select a single row
- 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?
- How to ORDER BY DESC and display the first 3 records in MySQL?
- 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
- Display sum in last row of table using MySQL?
- Counting pairs with range sum in a limit in JavaScript
- MySQL query to select rows except first row in descending order?
- Display records by first fixing the first two values in a column and then using DISTINCT to display other values in MySQL
- How to select first and last data row from a MySQL result?
- MySQL query to display the first alphabet from strings in a separate column
- Display 3 decimal places in MySQL?

Advertisements