带有联接的Oracle Update查询

编程入门 行业动态 更新时间:2024-10-27 00:31:48
本文介绍了带有联接的Oracle Update查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我知道update子句不适用于Oracle中的联接.

I do know update clause doesn't work with joins in Oracle.

update table1 Pr set code = (select t2.class_attr_value from table2 t2 where class_attr_name = 'sample' and Pr.epcclass_id = t2.epcclass_id)

如果有人可以帮助我修改查询,使我不会收到未正确结束的SQL Command错误,我将不胜感激.

I would be thankful if someone can help me modify my query so that I don't get the error of SQL Command not ended properly.

推荐答案

您的查询对我来说似乎还可以,我刚刚添加了表别名.您的查询将更新表1中的所有记录.您遇到什么错误...?

Your Query seems okay to me I just added Table Alias. Your query will update all records in table1. What error you are getting...??

建议

a)除非您要更新所有记录,否则请在查询中添加where子句,以避免更新所有记录...

a) Unless it's the intent that you want to update all records, add a where clause in the query to avoid updating all records...

b)如果要获取(ORA-01427:单行子查询返回多行),则意味着相关子查询(在方括号内)缺少某种条件,因此每个epcclass_id仅读取1行.

b) If you are getting (ORA-01427: single-row subquery returns more than one row) then means corelated sub query (within brackets) is missing some condition to make it fetch only 1 row per epcclass_id.

update table1 Pr set Pr.code = (select t2.class_attr_value from table2 t2 where t2.class_attr_name = 'sample' and t2.epclass_id = Pr.epcclass_id );

更多推荐

带有联接的Oracle Update查询

本文发布于:2023-06-08 14:30:23,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/583098.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Oracle   Update

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!