
- 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 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 Articles
- 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?
- MySQL LIKE command doesn't work with strings containing dots to display records beginning with a specific number
- Get the strings in the table records that ends with numbers?
- MySQL query to display only the records that contains single word?
- Display matching repeated date records only once in MySQL
- Create a Stored Procedure with MySQL and set a limit to display only a specific number of records
- 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?
- Alphanumeric Order by in MySQL for strings mixed with numbers
- Implement MySQL IN for 2 columns to display only selected records
- How to ignore specific records and add remaining corresponding records (numbers) in MySQL?
- Displaying only a list of records in ASC order with MySQL

Advertisements