让我们首先创建一个表-
mysql> create table DemoTable649 (Value text);
使用插入命令在表中插入一些记录-
mysql> insert into DemoTable649 values('1903'); mysql> insert into DemoTable649 values('9321010'); mysql> insert into DemoTable649 values('983032023393'); mysql> insert into DemoTable649 values('1234567892'); mysql> insert into DemoTable649 values('989898989');
使用select语句显示表中的所有记录-
mysql> select *from DemoTable649;
这将产生以下输出-
+--------------+ | Value | +--------------+ | 1903 | | 9321010 | | 983032023393 | | 1234567892 | | 989898989 | +--------------+ 5 rows in set (0.00 sec)
以下是使用正则表达式返回特定MySQL字符串的查询-
mysql> select *from DemoTable649 where Value REGEXP '[0-9]{11}';
这将产生以下输出-
+--------------+ | Value | +--------------+ | 983032023393 | +--------------+ 1 row in set (0.00 sec)