Mysql REPLACE 导致所有行的值为 0 [英] Mysql REPLACE resulted in 0 values on all rows

查看:56
本文介绍了Mysql REPLACE 导致所有行的值为 0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 MySQL 数据库中使用了以下 SQL 查询来替换单元格中的部分字符串:

I've used the following SQL query in a MySQL database to replace part of a string in a cell:

UPDATE TEST.database2014 SET together1 = REPLACE(together1, "/1900", "20")

出于某种原因,所有行(225,000!)现在的值为 0.

For some reason all the rows (225,000!) have now a value of 0.

这是我收到的消息:

/* 受影响的行:225,000 找到的行:0 警告:0 1 次查询的持续时间:16,888 秒.*/

/* Affected rows:225,000 Found rows: 0 Warnings: 0 Duration for 1 query: 16,888 sec. */

附加信息:字段 together1 中包含的数据示例:

ADDITIONAL INFORMATION: data example contained in field together1:

TESTING^^^19/01/2014^^

发生这种情况是否有已知原因?我觉得很奇怪,如果没有找到匹配项,它无论如何都会将所有值转换为 0.

Is there a known reason for this happening? I find it strange that if no matches where found it converted all values to 0 anyway.

推荐答案

我认为你必须使用这个:

I think that you must use this:

UPDATE TEST.database2014 SET together1 = REPLACE(together1, "/19", "/20") WHERE togheter1 LIKE '%/19%'

如果你想更新 1900 年到 2000 年的所有年份

if you want to upate all year 1900 to 2000

这篇关于Mysql REPLACE 导致所有行的值为 0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆