问题描述
嗨,
我有一张表
以下是dml上的操作:
还有一张表
以下是dml上的操作:
从temp2中选择 *
退货:
现在,我必须根据表temp1的product_id,区域和所有者更新表temp2的受让人列。temp2的主题列将具有temp1的区域列值作为子字符串。像temp2列主题 “这是管理服务器错误” 一样,具有子字符串 “管理服务器”,并且该子字符串存在于表temp1的区域列中。
我需要有如下的输出:
从temp2中选择 *;
请让我知道在表temp2上执行上述更新的sql
谢谢,
子哈希
我有一张表
create table temp1(product_id number, area varchar2(50), owner varchar2(50));复制
以下是dml上的操作:
insert into temp1(product_id ,area,owner) values(5757,'cordinated replicat', 'apushar'); insert into temp1(product_id ,area,owner) values(5757,'admin server', 'subhasku'); insert into temp1(product_id ,area,owner) values(5,'admin server', 'abc');复制
还有一张表
create table temp2(product_id number, subject varchar2(200),bug_number number, ASSIGNEE varchar2(50));复制
以下是dml上的操作:
insert into temp2(product_id ,subject ,bug_number) values(5757,'this is an Admin Server bug',1234); insert into temp2(product_id ,subject ,bug_number) values(5757,'this is a Cordinated Replicat bug',2345); insert into temp2(product_id ,subject ,bug_number) values(5,'this is an Admin Server bug',54321);复制
从temp2中选择 *
退货:
PRODUCT_ID SUBJECT BUG_NUMBER ASSIGNEE ----------- ------- ---------- -------- 5757 this is a Cordinated Replicat bug 1234 5757 this is an Admin Server bug 5678 5 this is an Admin Server bug 54321复制
现在,我必须根据表temp1的product_id,区域和所有者更新表temp2的受让人列。temp2的主题列将具有temp1的区域列值作为子字符串。像temp2列主题 “这是管理服务器错误” 一样,具有子字符串 “管理服务器”,并且该子字符串存在于表temp1的区域列中。
我需要有如下的输出:
从temp2中选择 *;
PRODUCT_ID SUBJECT BUG_NUMBER ASSIGNEE ----------- ------- ---------- -------- 5757 this is a Cordinated Replicat bug 1234 apushar 5757 this is an Admin Server bug 5678 subhasku 5 this is an Admin Server bug 54321 abc复制
请让我知道在表temp2上执行上述更新的sql
谢谢,
子哈希
专家解答
因此,当产品ID匹配且区域位于temp2的主题中时,您想从temp1.owner中设置temp2.assignee?
如果是这样,你需要一个相关的更新。在t1中选择匹配的行。您可以使用instr查看主题是否包含区域:
如果是这样,你需要一个相关的更新。在t1中选择匹配的行。您可以使用instr查看主题是否包含区域:
update temp2 t2 set assignee = ( select t1.owner from temp1 t1 where t1.product_id = t2.product_id and instr(lower(t2.subject), t1.area) > 0 ); 3 rows updated. select * from temp2; PRODUCT_ID SUBJECT BUG_NUMBER ASSIGNEE 5757 this is an Admin Server bug 1234 subhasku 5757 this is a Cordinated Replicat bug 2345 apushar 5 this is an Admin Server bug 54321 abc复制
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。
评论
相关阅读
Oracle RAC 一键安装翻车?手把手教你如何排错!
Lucifer三思而后行
596次阅读
2025-04-15 17:24:06
【纯干货】Oracle 19C RU 19.27 发布,如何快速升级和安装?
Lucifer三思而后行
567次阅读
2025-04-18 14:18:38
XTTS跨版本迁移升级方案(11g to 19c RAC for Linux)
zwtian
485次阅读
2025-04-08 09:12:48
Oracle数据库一键巡检并生成HTML结果,免费脚本速来下载!
陈举超
473次阅读
2025-04-20 10:07:02
【ORACLE】记录一些ORACLE的merge into语句的BUG
DarkAthena
457次阅读
2025-04-22 00:20:37
【ORACLE】你以为的真的是你以为的么?--ORA-38104: Columns referenced in the ON Clause cannot be updated
DarkAthena
432次阅读
2025-04-22 00:13:51
Oracle 19c RAC更换IP实战,运维必看!
szrsu
432次阅读
2025-04-08 23:57:08
【活动】分享你的压箱底干货文档,三篇解锁进阶奖励!
墨天轮编辑部
417次阅读
2025-04-17 17:02:24
火焰图--分析复杂SQL执行计划的利器
听见风的声音
362次阅读
2025-04-17 09:30:30
3月“墨力原创作者计划”获奖名单公布
墨天轮编辑部
358次阅读
2025-04-15 14:48:05