将两个表中的主键不同数据查找出来并添加到一张新表中的sql示例

//将两个表中的主键不同数据查找出来并添加到一张新表中

INSERT INTO t_user 
SELECT 
usera.userid, 
usera.name, 
usera.department, 
usera.position, 
usera.mobile, 
usera.gender, 
usera.email, 
usera.weixinid, 
usera.enable, 
usera.avatar, 
usera.status, 
usera.creattime, 
usera.updatetime, 
usera.creatuser FROM 
(
SELECT a.* 
FROM 
t_user_temp a 
WHERE NOT EXISTS 
( SELECT * FROM t_user_temp c INNER JOIN t_user b ON c.userid = b.userid WHERE a.userid = b.userid ) 
) usera;

    原文作者:Downe
    原文地址: https://blog.csdn.net/weixin_39851884/article/details/78226986
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞