Oracle数据库
方式一(推荐)
-- 将 t2表的字段更新到t1表
MERGE INTO COMMUNITY_MEMBER_APPLY_DIE T1
USING COMMUNITY_MEMBER T2
ON (T1.MEMBER_ID = T2.MEMBER_ID)
WHEN MATCHED THEN
UPDATE
SET T1.REAL_NAME = T2.USER_NAME,
T1.CARD_NUM=T2.CARDNUM
where T1.CARD_NUM is null
or T1.REAL_NAME is null;
方式二
-- 将 t2表的字段更新到t1表
update COMMUNITY_MEMBER_APPLY_DIE T1
set (REAL_NAME, CARD_NUM)
= (select T2.USER_NAME, T2.CARDNUM from COMMUNITY_MEMBER T2 where T1.MEMBER_ID = T2.MEMBER_ID)
where T1.CARD_NUM is null
or T1.REAL_NAME is null;
方式一比方式二效率快很多文章来源地址https://www.toymoban.com/news/detail-731330.html
MySQL数据库
-- 将 t2表的字段更新到t1表
update org T1, community_area T2
set T1.prov=T2.province,
T1.city=T2.city,
T1.dist=T2.district,
T1.street=T2.town,
T1.community=T2.village
where T1.area_code = T2.area_code;
文章来源:https://www.toymoban.com/news/detail-731330.html
到了这里,关于数据库将一张表中的数据更新到另一张表(Oracle、MySQL)的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!