
- 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 LIKE command doesn't work with strings containing dots to display records beginning with a specific number
To work with strings containing dots, and display records beginning with a specific number, you need to use REGEXP. Let us first create a table −
mysql> create table DemoTable -> ( -> GameReleaseVersion varchar(20) -> ); Query OK, 0 rows affected (0.57 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values('19.6'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values('18.4'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable values('17.6'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable values('19.5'); Query OK, 1 row affected (0.14 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+--------------------+ | GameReleaseVersion | +--------------------+ | 19.6 | | 18.4 | | 17.6 | | 19.5 | +--------------------+ 4 rows in set (0.00 sec)
Here is the query that works with a string containing dots. We are fetching records beginning with 19 with some other conditions after dot −
mysql> select *from DemoTable -> where GameReleaseVersion regexp '^19\.[0-9]+$';
This will produce the following output −
+--------------------+ | GameReleaseVersion | +--------------------+ | 19.6 | | 19.5 | +--------------------+ 2 rows in set (0.15 sec)
- Related Articles
- MySQL REGEXP to fetch string + number records beginning with specific numbers?
- MySQL regexp to display only records with strings or strings mixed with numbers. Ignore only the number records
- MongoDB query to find records with keys containing dots?
- Display specific table names with MySQL LIKE Operator
- Finding only strings beginning with a number using MySQL Regex?
- Create a Stored Procedure with MySQL and set a limit to display only a specific number of records
- MySQL query to select records beginning from a specific id
- How to get the maximum value from a column with alphanumeric strings beginning with specific characters in MYSQL?
- MySQL query to display records from a table filtered using LIKE with multiple words?
- MySQL RegExp to fetch records with only a specific number of words
- How to select records beginning with certain numbers in MySQL?
- Fetch records containing a specific character twice in MySQL
- Query MongoDB with “like” implementation on name and email field beginning with a specific letter?
- Find the records with % character in a LIKE query with MySQL
- How to display records vertically in MySQL command line?

Advertisements