Oracle数据库
方式一(推荐)
-- 将 t2表的字段更新到t1表
MERGE INTO ***MUNITY_MEMBER_APPLY_DIE T1
USING ***MUNITY_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 ***MUNITY_MEMBER_APPLY_DIE T1
set (REAL_NAME, CARD_NUM)
= (select T2.USER_NAME, T2.CARDNUM from ***MUNITY_MEMBER T2 where T1.MEMBER_ID = T2.MEMBER_ID)
where T1.CARD_NUM is null
or T1.REAL_NAME is null;
方式一比方式二效率快很多
MySQL数据库
-- 将 t2表的字段更新到t1表
update org T1, ***munity_area T2
set T1.prov=T2.province,
T1.city=T2.city,
T1.dist=T2.district,
T1.street=T2.town,
T1.***munity=T2.village
where T1.area_code = T2.area_code;