带联接的SQL更新

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

我有当前从 table2.oldData 填充的数据 table1.fieldToChange ...,但我想对其进行更新并将其更改为 table2. newData

I have data table1.fieldToChange that is currently populated from table2.oldData... but I would like to update this and change it to table2.newData

这是我用来尝试实现此目标的代码:

Here's the code I am using to try and achieve this:

UPDATE table1 SET table1.fieldToChange = (SELECT table2.newData FROM table2 WHERE table2.oldData = table1.newData ) ;

但是我收到"ORA-01427"错误.

But I get an 'ORA-01427' error.

table2.newData 和 table2.oldData 都是唯一的标识符,在数据库中仅使用一次.任何帮助将不胜感激!

Both table2.newData and table2.oldData are unique identifiers and only used once in the database. Any help would be much appreciated!

谢谢

推荐答案

您不是故意的吗?

UPDATE table1 SET fieldToChange = (SELECT table2.newData FROM table2 WHERE table2.oldData = table1.fieldToChange ---- and NOT table1.newData ? ) ;

更多推荐

带联接的SQL更新

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

发布评论

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

>www.elefans.com

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