在我的数据库中,我有一些类似这样的两列记录:
Id, Name,
11, Meal 997,
12, Meal 998,
13, Meal 999,
14, Meam 000,
15, Meam 001,
16, Meam 002,
但这是应用程序中的一个问题,由于逻辑错误而导致数据错误。 如何将包含 Meam 的记录更改为 Meal 并继续递增?
上面的记录应该是这样的:
11, Meal 997,
12, Meal 998,
13, Meal 999,
14, Meal 1000,
15, Meal 1001,
16, Meal 1002,
我们如何更改数据库?
“Meam 001”将在一列中
查询是什么?
最佳答案
update tablename
set name=replace(name,'Meam','Meal 1')
where name like "Meam%"
您可以使用以下方法进行测试:
select name, replace(name,'Meam','Meal 1')
from tablename
;)
关于mysql - 在 MySQL 中替换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5094300/