有料ユーザー・テーブルを合計ユーザー・テーブルにマージ


有料ユーザテーブル(pay_user_info)には、(imsi,create_time作成時間,channelチャネル番号)の3つのフィールドしかありません.ユーザテーブル(user_info)には、(imsi,create_time作成時間、channelチャネル番号、typeタイプ)などのフィールドがあります.typeは、ユーザが(type=1)アプリケーションを開いたか、読んだか(type=2)または有料(type=3)であるかを示す.
1、料金表の記録は、ユーザー表にすでに存在し、typeを3に変更する必要がある.
update user_info u 
set type=3  
where exists 
(select * from pay_user_info p where u.imsi=p.imsi);

2、料金表の記録は、ユーザー表には存在せず、ユーザー表に追加する必要がある.
insert into user_info(imsi,create_time,channel,type)
select imsi,create_time,channel,3 from pay_user_info p
where not exists 
(select * from user_info u where p.imsi=u.imsi)