
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Remove Value with Only Numbers in MySQL 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)
Advertisements