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)