[オラクル]値の複数のフィールドは、状況に応じて更新します

需要

Nフィールドのテーブル値を更新します。

図1に示すように、フィールドAの値に応じて、フィールドBは、値に更新されます

フィールド条件更新の値に応じて2、

方法

複数のフィールドを更新します。

-- 方法一
update a set a.province=(select province from b where b.mobile=a.mobile);
update a set a.city=(select city from b where b.mobile=a.mobile);

-- 方法二
update a set a.province=b.province,a.city=b.city from a,b where a.mobile=b.mobile;
update a set a.province=b.province,a.city=b.city from a inner join b on a.mobile=b.mobile;

-- 方法三
update a inner join b on a.mobile=b.mobile set a.province=b.province,a.city=b.city;

-- 方法四(最优)
update a set(a.province,a.city)=(select province,city from b where b.mobile=a.mobile);

更新フィールドの条件によると、

update t_cure_plan a
   set (inject) =
       (select case
                 when inject = '第一针' then
                  '1'
                 when inject = '第二针' then
                  '2'
                 else
                  inject
               end as newInject
          from t_cure_plan b
         where a.id = b.id);

オラクル:セットテーブルのフィールドの複数
のOracle:のフィールド値の条件を決定することによって、データベースを更新します

公開された107元の記事 ウォン称賛88 ビュー260 000 +

おすすめ

転載: blog.csdn.net/Code_shadow/article/details/104043502