我需要找到並替換表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