
- 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 remove a value with only numbers in a column
For this, you can use REGEXP. Let us first create a table −
mysql> create table DemoTable -> ( -> ClientCode varchar(100) -> ); Query OK, 0 rows affected (0.56 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values('Chris902'); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable values('Robert_'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values('903'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values('123_David'); Query OK, 1 row affected (0.21 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
Output
This will produce the following output −
+------------+ | ClientCode | +------------+ | Chris902 | | Robert_ | | 903 | | 123_David | +------------+ 4 rows in set (0.00 sec)
Following is the query to SQL like statement “%[^0-9]%” not working −
mysql> select *from DemoTable where ClientCode REGEXP '.*[^0-9].*';
Output
This will produce the following output −
+------------+ | ClientCode | +------------+ | Chris902 | | Robert_ | | 123_David | +------------+ 3 rows in set (0.04 sec)
- Related Articles
- MySQL query to remove numbers after hyphen in a VARCHAR string with numbers
- MySQL query to remove Null Records in a column?
- MySQL query to replace a column value
- How to remove only the first word from columns values with a MySQL query?
- Updating only a single column value in MySQL?
- Update only a single column value in MySQL
- Add user defined value to a column in a MySQL query?
- How to use MySQL LIKE query to search a column value with % in it?
- MySQL query to remove string from a column with values EMP1, EMP2, EMP3, etc.
- MySQL query to display only the column values with corresponding column having whitespace
- Calculate average of numbers in a column MySQL query?
- MySQL query to select rows where column value is only 0, group by another column?
- Replace only a specific value from a column in MySQL
- MySQL query to retrieve only the column values with special characters?
- Two ways to fetch maximum value from a MySQL column with numbers

Advertisements