Oracle通过join选择/更新 [英] Oracle select/update with join
问题描述
我有tableA和tableB可以通过id加入。我试图弄清楚如何编写它,以便我可以选择tableA.color和tableB.value并对tableA中的列进行更新,名为 颜色从行的蓝色变为红色,但仅当tableB中名为 value 的列大于10时才会更改。
所以结果集
颜色 价值
蓝色7
蓝色3
红色12
蓝色1
红色14
我的尝试:
我在想什么
< pre>从tableA
内连接中选择tableA.color,tableB.value
tableB on tableA.id = tableB.id
update tableA
set tableA.color =red
where tableB.value> 10
不确定语法和包括连接。
< blockquote>检查: Oracle / PLSQL:UPDATE Statement [ ^ ]
在那里你会找到一种基于第二个值更新数据的方法表
I have tableA and tableB which can join by ids. I am trying to figure out how to write it such that I can select the tableA.color and tableB.value and do an update for the column in tableA called color that will get changed from "blue" to "red" for a row but only if the column in tableB called value is greater than 10.
so the result set
color value
blue 7
blue 3
red 12
blue 1
red 14
What I have tried:
I was thinking something along the lines of
<pre>select tableA.color, tableB.value from tableA inner join tableB on tableA.id = tableB.id update tableA set tableA.color = "red" where tableB.value > 10
Wasn't sure on syntax and including the join.
Check this: Oracle / PLSQL: UPDATE Statement[^]
There you'll find a way to update data based on values in second table.
这篇关于Oracle通过join选择/更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!