MySQL Update query with LIKE in WHERE clause not affecting matching rows

人走茶凉 提交于 2019-12-13 05:09:42

问题


This is driving me crazy. I do a SELECT first to make sure records exist:

Select * from gems WHERE page2 like '%acids-bases-salts%'

and get

Showing rows 0 - 8 ( 9 total, Query took 0.0012 sec)

Then try to UPDATE to change those records:

UPDATE gems SET page2 = replace(page2, 'acids-bases-salts', 'abs') WHERE page2 LIKE '%acids-bases-salts%'

and get

0 rows affected. ( Query took 0.0019 sec )

What am I missing? This is simple one time query so I am not worried about performance.


回答1:


OK got it. The replace() is case sensitive but the WHERE clause is not.



来源:https://stackoverflow.com/questions/20038101/mysql-update-query-with-like-in-where-clause-not-affecting-matching-rows

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