MySQL regexp只显示带有字符串或带有数字的字符串的记录。只忽略号码记录
为此,您可以使用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)
以下是对MySQLregexp的查询-
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)
热门推荐
10 广西考试祝福语结婚简短
11 猪年祝福语简短小孩
12 元旦祝福语送长辈简短
13 恭喜二宝祝福语简短
14 祝福语暖心话简短
15 国庆中秋祝福语简短兄弟
16 朋友订婚的祝福语简短
17 送弟弟中秋祝福语简短
18 爱生日祝福语简短独特