回答

收藏

用另一列中的值更新列

技术问答 技术问答 267 人阅读 | 0 人回复 | 2023-09-12

我有这样一个表:1 C# ], {* `7 M7 B2 x& N
create table foo ( a number,b number )我想用另一个表中的值更新a的所有列& `8 ?+ l* s4 C' A9 M$ P$ @
create table bar ( x number,y number )因此,如果这将是一种程序编程语言,我将:
) K4 c1 S+ U' P' p    foreach foo_item in foo      foreach bar_item in bar          if( foo_item.b == bar_item.y )                 foo_item.a = bar_item.x          end     end end我试过了# S. Z- g* }2 J
update foo set a = ( select distinct( x ) from bar where bar.y = foo.b )但它挂起了…。    我不确定怎么做(甚至不知道谷歌该怎么做)
1 X$ l1 _+ }, z谢谢
; y! f! x: c9 l- s* S7 U# h编辑    对不起,我不好。它不会挂起来,但会尝试设置va null值,我有约束(不能删除)
/ c# N, I. l$ r+ j3 b- l! s3 Z感谢您目前的帮助
$ M- i# d* n. l" g3 d                                                               
5 [0 V" ~2 M; R- f3 d) Z    解决方案:
分享到:
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则