Mysql 更新未按预期更新 select

Mysql Update doesn't update as expected with select

我有一个很大的 mysql table(2000 万条记录),我在其中使用替换和在哪里进行了更新。我 运行 它更新了大部分记录但是当我重新 运行 table 上的 Select 与备份我仍然有 6 或 7 条记录与之前的 556 对比。以防万一我重新 运行 更新语句,它更新了 0 条记录,然后简单地将它从

更改为
Update TableA set FieldA=Replace(FieldA,'1 ','1st ') where FieldA like '%1 %'

Select FieldA,Replace(FieldA,'1 ','1st ') where FieldA like ' %'

select 找到了 6 条杂散记录,并且替换按预期执行。我不清楚更新如何不起作用。

更新:经过审查,我意识到我在 table 上添加了一个唯一键, 包括 该字段等。当我第一次尝试 运行 更新时,我得到了那个错误,然后我 运行 作为 Update IGNORE。我认为这意味着它会忽略密钥并无论如何进行更新,这是否仅仅意味着它没有更新会导致重复的记录但由于忽略而移动到下一条记录?

正如 mysql 关于 update command 的文档所说:

With the IGNORE keyword, the update statement does not abort even if errors occur during the update. Rows for which duplicate-key conflicts occur on a unique key value are not updated. Rows updated to values that would cause data conversion errors are updated to the closest valid values instead.

所以,是的,忽略关键字导致了所描述的行为。使用show warnings命令查看update ignore语句引起的警告。