

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
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
MySQL regexp to display only records with strings or strings mixed with numbers. Ignore only the number records
For this, you can use REGEXP. Following is the syntax −
select yourColumnName from yourTableName where yourColumnName REGEXP '[a−zA&minu;Z]';
Let us create a table −
mysql> create table demo41 −> ( −> name varchar(40) −> ); Query OK, 0 rows affected (0.64 sec)
Insert some records into the table with the help of insert command −
mysql> insert into demo41 values('John Smith34') −> ; Query OK, 1 row affected (0.13 sec) mysql> insert into demo41 values('John Smith'); Query OK, 1 row affected (0.11 sec) mysql> insert into demo41 values('9234John Smith'); Query OK, 1 row affected (0.14 sec) mysql> insert into demo41 values('john smith'); Query OK, 1 row affected (0.23 sec) mysql> insert into demo41 values('98775'); Query OK, 1 row affected (0.15 sec)
Display records from the table using select statement −
mysql> select *from demo41;
This will produce the following output −
+----------------+ | name | +----------------+ | John Smith34 | | John Smith | | 9234John Smith | | john smith | | 98775 | +----------------+ 5 rows in set (0.00 sec)
Following is the query for MySQL regexp −
mysql> select name from demo41 where name REGEXP '[a−zA−Z]';
This will produce the following output −
+----------------+ | name | +----------------+ | John Smith34 | | John Smith | | 9234John Smith | | john smith | +----------------+ 4 rows in set (0.00 sec)
- Related Questions & Answers
- MySQL RegExp to fetch records with only a specific number of words
- MySQL REGEXP to fetch string + number records beginning with specific numbers?
- Implement MySQL REGEXP to fetch records with . and numbers
- Finding only strings beginning with a number using MySQL Regex?
- Get the strings in the table records that ends with numbers?
- Alphanumeric Order by in MySQL for strings mixed with numbers
- Display matching repeated date records only once in MySQL
- MySQL query to display only the records that contains single word?
- Use MySQL REGEXP to ignore number and get only String and '/'
- Display only the employee names with specific salaries in MongoDB documents with employee records?
- MySQL LIKE command doesn't work with strings containing dots to display records beginning with a specific number
- Implement MySQL IN for 2 columns to display only selected records
- How to ignore specific records and add remaining corresponding records (numbers) in MySQL?
- Create a Stored Procedure with MySQL and set a limit to display only a specific number of records
- Displaying only a list of records in ASC order with MySQL
Advertisements