mysql 从另一张表插入到另一张表中

mysql 数据表拷贝

INSERT
	INTO
	table1(uniacid ,
	openid ,
	mobile ,
	nickname ,
	real_name )
SELECT
	b.uniacid,
	b.openid,
	b.mobile,
	b.nickname,
	b.realname
FROM
	table2 AS a
left join table2 AS b on
	a.pid = b.id
left join table1 AS c on
	c.openid = b.openid
where
	a.recruit_provider_id = 0
	AND a.pid>0
	AND b.openid != ''
	AND IFNULL(c.id,
	0)= 0

你可能感兴趣的:(sql)