数据库操作

INSERT INTO tim_mentorship_user ( id, user_name, user_code, user_grade, create_time,
 update_time, operator, creator, remark, is_delete ) SELECT DISTINCT
	user_id,
	user_name,
	user_code,
	organization_name,
	tk.create_time,
	tk.update_time,
	tk.operator,
	tk.creator,
	tk.remark,
	tk.is_delete 
FROM
	tc_organization_user AS tc
	LEFT JOIN tik_user AS tk ON tc.user_id = tk.id
	LEFT JOIN tc_organization AS tco ON tco.id = tc.organization_id 
WHERE
	tk.is_delete = 0 AND
	organization_id = '**************'
	ON DUPLICATE KEY UPDATE user_name = tk.user_name,
	user_code = tk.user_code,
	user_grade = tco.organization_name,
	create_time = tk.create_time,
	update_time = now(),
	operator = tk.operator,
	creator = tk.creator,
	remark = tk.remark,
	is_delete = tk.is_delete

你可能感兴趣的:(小桔Java)