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 新房祝福语简短10字
14 长辈新年祝福语大全简短
15 新年给大家简短祝福语
16 生日祝福语简短独特姑姑
17 芭比的婚礼祝福语简短
18 邀请新人祝福语简短英文