mysql 多表数据同步到一张表中

现有3张表,2张同步表,一张本地表,现在需要将同步表中的数据更新到本地表中。mysql 因为不支持 全关联,所以只能使用左、右分别关联两张表的方式获取全量信息。
通过insert select from 的方式,合并表数据。

INSERT INTO cust_first_trade(
	cust_id,
	htsc_first_trade_dt,
  zd_first_trade_dt
)SELECT
	a.client_id,a.first_trade_date,b.trading_date
FROM
	cust_sjzx.client_first_trade a
LEFT JOIN cust_sjzx.first_trade_date b ON a.client_id = b.client_id
 union 
SELECT
   d.client_id,c.first_trade_date,d.trading_date
from cust_sjzx.client_first_trade c
RIGHT JOIN cust_sjzx.first_trade_date d ON c.client_id = d.client_id
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值