Mysql REPLACE resulted in 0 values on all rows

时光总嘲笑我的痴心妄想 提交于 2020-01-17 03:59:17

问题


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")

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

This is the message which I got:

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

ADDITIONAL INFORMATION: data example contained in field together1:

TESTING^^^19/01/2014^^

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.


回答1:


I think that you must use this:

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

if you want to upate all year 1900 to 2000



来源:https://stackoverflow.com/questions/27417833/mysql-replace-resulted-in-0-values-on-all-rows

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!