This question already has answers here:
How do I UPDATE from a SELECT in SQL Server?
                                
                                    (33个答案)
                                
                        
                                5年前关闭。
            
                    
嗨,我有两张桌子...

活动表:


  选择*从36496839_radioamater.skladovekarty00006;


CISLO    NAME
1        NULL
2        NULL
3        NULL                  (other cells)
4        NULL
5        NULL


有用的表


  选择*从36496839_radioamater.skladovekarty00008;


CISLO    NAME
1        one
4        four
3        tree                  (other cells)


我需要创建一个SQL代码,该代码从table00006的table00008中查找第一行,并通过匹配CISLO复制NAME中的值

结果:

CISLO    NAME
1        one
2        NULL
3        tree                  (other cells)
4        four
5        NULL


因此需要重新建模12000行

谁能帮助我我拼命
马丁(Thx)

最佳答案

update 36496839_radioamater.skladovekarty00006 d
join 36496839_radioamater.skladovekarty00008 s on s.CISLO = d.CISLO
set d.NAME = s.NAME

10-08 19:56