- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
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
How to select records beginning with certain numbers in MySQL?
The optimal solution to select records beginning with certain numbers, use MySQL LIKE operator. Let us first create a table −
mysql> create table DemoTable ( ClientId bigint, ClientName varchar(40) ); Query OK, 0 rows affected (0.82 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values(23568777,'Chris Brown'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable values(9085544,'John Doe'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values(9178432,'John Doe'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable values(9078482,'David Miller'); Query OK, 1 row affected (0.17 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+----------+--------------+ | ClientId | ClientName | +----------+--------------+ | 23568777 | Chris Brown | | 9085544 | John Doe | | 9178432 | John Doe | | 9078482 | David Miller | +----------+--------------+ 4 rows in set (0.00 sec)
Following is the query to select records beginning with certain numbers in MySQL −
mysql> select *from DemoTable where ClientId LIKE '90%';
This will produce the following output −
+----------+--------------+ | ClientId | ClientName | +----------+--------------+ | 9085544 | John Doe | | 9078482 | David Miller | +----------+--------------+ 2 rows in set (0.00 sec)
- Related Articles
- MySQL REGEXP to fetch string + number records beginning with specific numbers?
- MySQL query to select records beginning from a specific id
- How to select all the records except a row with certain id from a MySQL table?
- MySQL Stored Procedure to update records with certain condition?
- Round records with numbers in MySQL
- How to select records that begin with a specific value in MySQL?
- Select particular type of columns beginning with a certain letter and concatenate the names
- MySQL query to select records with a particular date?
- Select records with ACTIVE status in MySQL set with ENUM
- How to update records in a column with random numbers in MySQL?
- MySQL query to select column values ending with certain character/number?
- How to use MySQL SELECT LEFT to fetch the records containing string with slash
- Return records that do not have a value in a certain field with two SELECT statement in a single MySQL query
- Get records in a certain order using MySQL?
- Implement MySQL REGEXP to fetch records with . and numbers

Advertisements