我知道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查询
发布评论