MySQL 查询删除列中仅包含数字的值
mysqlmysqli database更新于 2025/5/23 13:32:17
为此,您可以使用 REGEXP。让我们首先创建一个表 −
mysql> create table DemoTable -> ( -> ClientCode varchar(100) -> ); Query OK, 0 rows affected (0.56 sec)
使用 insert 命令在表中插入一些记录 −
mysql> insert into DemoTable values('Chris902');
Query OK, 1 row affected (0.21 sec)
mysql> insert into DemoTable values('Robert_');
Query OK, 1 row affected (0.14 sec)
mysql> insert into DemoTable values('903');
Query OK, 1 row affected (0.15 sec)
mysql> insert into DemoTable values('123_David');
Query OK, 1 row affected (0.21 sec)
使用 select 语句显示表中的所有记录 −
mysql> select *from DemoTable;
输出
这将产生以下输出 −
+------------+ | ClientCode | +------------+ | Chris902 | | Robert_ | | 903 | | 123_David | +------------+ 4 rows in set (0.00 sec)
以下是 SQL 类语句 “%[^0-9]%” 的查询,但不起作用 −
mysql> select *from DemoTable where ClientCode REGEXP '.*[^0-9].*';
输出
这将产生以下输出 −
+------------+ | ClientCode | +------------+ | Chris902 | | Robert_ | | 123_David | +------------+ 3 rows in set (0.04 sec)
相关文章
有用资源
mysql 参考教程 - 该教程包含有关 mysql 的更多信息:https://www.cainiaomax.com/mysql/

