Advertisement
Advertisement

新足迹

 找回密码
 注册
新足迹 门户 IT专业论坛 查看内容

求教写一段SQL语句。用表2中的一系列关键字替换表1内容

2020-3-31 19:13| 发布者: 汪汪汪 | 查看: 1864| 原文链接

Table A  中字段 item 是字符类的数据。
内容比如是:
item1
item2
item3
...

Table B 中字段Key 与 New 也是字符类。
key1, new1
key2, new2
key3, new3


请问如何用一段SQL做到:
在table A中每一条item中的字符 查找 b表中的每一个key 并用相应的new 替换。

即:对应每一条内容item,有很多个关键字key需要用对应的新字符new替换。
如果一条条做太累了。

Update TableA SET item = REPLACE(item, 'key1', 'new1') ;
Update TableA SET item = REPLACE(item, 'key2', 'new2') ;
...
...


key 与new已经做在表B中了。能否用一条语句做到?



Advertisement
Advertisement


Advertisement
Advertisement
返回顶部