仅供工作记录:
UPDATE crm_niche_team cnt,
crm_niche cn,
set_person sp,
set_department sd
SET cnt.person_id = cn.principal_person_id,
cnt.person_name = cn.principal_person_name,
cnt.department_id = sp.department_id,
cnt.department_path = sd.path,
cnt.person_path = sp.path
WHERE
cnt.niche_id = cn.id
AND cnt.is_principal = 1
AND cnt.person_id != cn.principal_person_id
AND cn.is_open = 0
-- 根据某个公司 AND cnt.org_id = 633675070786502656
AND cn.principal_person_id = sp.id
AND sp.department_id = sd.id
查询不一致的数据
SELECT
crm_niche.principal_person_id,
crm_niche.principal_person_name,
crm_niche.id AS nicheId,
crm_niche_team.*
FROM
crm_niche,
crm_niche_team
WHERE
crm_niche.id = crm_niche_team.niche_id
AND crm_niche.principal_person_id != crm_niche_team.person_id
AND crm_niche_team.is_principal = 1
AND crm_niche.org_name = "公司"
AND crm_niche.is_open = 0