在 WHERE 子句中使用 LIKE 的 MySQL 更新查询不影响匹配的行 [英] MySQL Update query with LIKE in WHERE clause not affecting matching rows
本文介绍了在 WHERE 子句中使用 LIKE 的 MySQL 更新查询不影响匹配的行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这让我发疯.我首先执行 SELECT
以确保记录存在:
This is driving me crazy. I do a SELECT
first to make sure records exist:
Select * from gems WHERE page2 like '%acids-bases-salts%'
并得到
Showing rows 0 - 8 ( 9 total, Query took 0.0012 sec)
然后尝试UPDATE
来改变那些记录:
Then try to UPDATE
to change those records:
UPDATE gems SET page2 = replace(page2, 'acids-bases-salts', 'abs') WHERE page2 LIKE '%acids-bases-salts%'
并得到
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.
推荐答案
好的,明白了.replace()
区分大小写,但 WHERE 子句不区分.
OK got it. The replace()
is case sensitive but the WHERE clause is not.
这篇关于在 WHERE 子句中使用 LIKE 的 MySQL 更新查询不影响匹配的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文