我需要找到并替换表multiplie字符串“短语”使用表“字典”找到并从另一个表的MySQL
取代我有这样的代码:
update phrases, dict
set phrases.name = replace(phrases.name, dict.source, dict.translate)
where phrases.name <> replace(phrases.name, dict.source, dict.translate)
pharses表例如:
id | name | .. | ..
1 | macbook wht comput | ..
2 | lenova blck god nb | ..
字典表例如:
id | source | translate
1 | wht | white
2 | god | good
3 | lenova | lenovo
4 | blck | black
5 | comput | computer
6 | nb | notebook
我需要得到法勒斯是这样的:
id | name | .. | ..
1 | macbook white computer | ..
2 | lenova black good notebook | ..
它将一行一次仅更换1串,但我有3-10串来代替。
如何更改此代码以替换行中的所有字符串?
可以提供例如数据的几行,好吗? – 2014-09-22 09:24:16
@ user2421781你是否检查了这篇文章? – 2014-09-22 09:49:41
[在另一个表中使用数据在MySQL中查找和替换字符串]可能的重复(http://stackoverflow.com/questions/2509835/find-and-replace-string-in-mysql-using-data-from-another-表) – fancyPants 2014-09-22 10:01:22