问题
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