当前位置 博文首页 > iloki的博客:oracle update

    iloki的博客:oracle update

    作者:[db:作者] 时间:2021-08-25 12:48

    --更新高价件表中的型号, hm_material h1
    update hm_highrate_material h
       set h.material_model =select h1.model from hm_material h1
     where h.material_id = h1.material_id);
    
    --对表A的a2,a3进行更新(带条件);
    update A
       set (A.a2, A.a3) =
           (select B.b2, b.b3
              from B
             where B.b1 = A.a1 and A.a3 = 100)
     where exists (select 'X'
              from B
             where B.b1 = A.a1 and A.a3 = 100);
     
     
    --或者: 
    update A
       set (A.a2, A.a3) =
           (select B.b2, b.b3
              from B
             where B.b1 = A.a1 and A.a3 = 100)
             where A.a1 in (select B.b1
                               from B
                              where B.b1 = A.a1 and A.a3 = 100);
    
    cs
    下一篇:没有了