
- 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
Implement MySQL REGEXP to fetch records with . and numbers
Let us first create a table −
mysql> create table DemoTable -> ( -> Version varchar(20) -> ); Query OK, 0 rows affected (0.77 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values('1.0.0'); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable values('2.s6.9'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable values('1.5.0'); Query OK, 1 row affected (0.12 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+---------+ | Version | +---------+ | 1.0.0 | | 2.s6.9 | | 1.5.0 | +---------+ 3 rows in set (0.00 sec)
Here is the query to implement MySQL REGEXP to fetch records with . and numbers −
mysql> select *from DemoTable -> where Version regexp '^[0-9]+\.[0-9]+(\.[0-9]+)*';
This will produce the following output −
+---------+ | Version | +---------+ | 1.0.0 | | 1.5.0 | +---------+ 2 rows in set (0.00 sec)
- Related Articles
- MySQL REGEXP to fetch string + number records beginning with specific numbers?
- MySQL RegExp to fetch records with only a specific number of words
- MySQL regexp to display only records with strings or strings mixed with numbers. Ignore only the number records
- MySQL query for text search with LIKE and OR to fetch records
- MySQL query to fetch records with arrangement in the form of numbers and letter like 99S, 50K, etc.?
- MySQL query to find a match and fetch records
- How to order records and fetch some using MySQL LIMIT?
- Round records with numbers in MySQL
- Fetch date records comparing with the current date’s day and month in MySQL
- Order VARCHAR records with string and numbers in MySQL
- MySQL to fetch records based on a specific month and year?
- MySQL query to fetch the latest date from a table with date records
- MySQL query to fetch records before currentdate + 2 weeks?
- How to use MySQL SELECT LEFT to fetch the records containing string with slash
- Fetch maximum individual marks for a student with marks1 and marks2 records in MySQL?

Advertisements