为此,您可以使用REGEXP。以下是语法-
select yourColumnName from yourTableName where yourColumnName REGEXP '[a−zA&minu;Z]';
让我们创建一个表-
mysql> create table demo41 −> ( −> name varchar(40) −> );
借助insert命令将一些记录插入表中-
mysql> insert into demo41 values('John Smith34') −> ; mysql> insert into demo41 values('John Smith'); mysql> insert into demo41 values('9234John Smith'); mysql> insert into demo41 values('john smith'); mysql> insert into demo41 values('98775');
使用select语句显示表中的记录-
mysql> select *from demo41;
这将产生以下输出-
+----------------+ | name | +----------------+ | John Smith34 | | John Smith | | 9234John Smith | | john smith | | 98775 | +----------------+ 5 rows in set (0.00 sec)
以下是对MySQL regexp的查询-
mysql> select name from demo41 where name REGEXP '[a−zA−Z]';
这将产生以下输出-
+----------------+ | name | +----------------+ | John Smith34 | | John Smith | | 9234John Smith | | john smith | +----------------+ 4 rows in set (0.00 sec)