MySQL查询删除第一个数字?

为此,请使用SUBSTR()。以下是语法-

update yourTableName set yourColumnName=substr(yourColumnName,2);

让我们首先创建一个表-

create table DemoTable607 (Value varchar(100));

使用插入命令在表中插入一些记录-

insert into DemoTable607 values('83967364');
insert into DemoTable607 values('10939432');
insert into DemoTable607 values('932111');

使用select语句显示表中的所有记录-

select *from DemoTable607;

这将产生以下输出-

+----------+
| Value    |
+----------+
| 83967364 |
| 10939432 |
| 932111   |
+----------+
3 rows in set (0.00 sec)

这是删除第一个数字的MySQL查询-

update DemoTable607 set Value=substr(Value,2);
Rows matched: 3 Changed: 3 Warnings: 0

让我们再次检查表-

select *from DemoTable607;

这将产生以下输出-

+---------+
| Value   |
+---------+
| 3967364 |
| 0939432 |
| 32111   |
+---------+
3 rows in set (0.00 sec)