
- 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 query to select records beginning from a specific id
Let us first create a table −
mysql> create table DemoTable -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> Name varchar(100) -> ); Query OK, 0 rows affected (0.67 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable(Name) values('John'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable(Name) values('David'); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable(Name) values('Carol'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable(Name) values('Bob'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable(Name) values('Mike'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable(Name) values('Chris'); Query OK, 1 row affected (0.22 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
Output
+----+-------+ | Id | Name | +----+-------+ | 1 | John | | 2 | David | | 3 | Carol | | 4 | Bob | | 5 | Mike | | 6 | Chris | +----+-------+ 6 rows in set (0.00 sec)
Following is the query to select records beginning from a specific id.
mysql> select *from DemoTable where Id>=2 order by Id DESC;
Output
+----+-------+ | Id | Name | +----+-------+ | 6 | Chris | | 5 | Mike | | 4 | Bob | | 3 | Carol | | 2 | David | +----+-------+ 5 rows in set (0.00 sec)
- Related Articles
- MySQL SELECT query to return records with specific month and year
- MySQL query to select all the records only from a specific column of a table with multiple columns
- How to select records beginning with certain numbers in MySQL?
- MySQL query to select top 10 records?
- MySQL query to select bottom n records
- MySQL query to select distinct order by id
- MySQL query to select records with a particular date?
- How to get a specific column record from SELECT query in MySQL?
- MySQL REGEXP to fetch string + number records beginning with specific numbers?
- How to select all the records except a row with certain id from a MySQL table?
- How to write a MySQL query to select first 10 records?
- MySQL query to fetch specific records matched from an array (comma separated values)
- MySQL query to select a specific string with special characters
- MySQL query to select records with a particular date and time?
- MySQL query to select records from a table on the basis of a particular month number?

Advertisements