SQL update from one Table to another based on a ID match

后端 未结 22 1295
太阳男子
太阳男子 2020-11-21 22:49

I have a database with account numbers and card numbers. I match these to a file to update any card numbers to the account number, so

22条回答
  •  被撕碎了的回忆
    2020-11-21 23:19

    I had the same problem with foo.new being set to null for rows of foo that had no matching key in bar. I did something like this in Oracle:

    update foo
    set    foo.new = (select bar.new
                      from bar 
                      where foo.key = bar.key)
    where exists (select 1
                  from bar
                  where foo.key = bar.key)
    

提交回复
热议问题