-- 同步6个业绩表的品项名称字段
-- 通过关联的品项明细表获取品项名称（pxmc字段）

-- 1. 开单健康师业绩表：从开单品项明细表（lq_kd_pxmx）同步
UPDATE lq_kd_jksyj kd
INNER JOIN lq_kd_pxmx px ON px.F_Id = kd.F_kdpxid
SET kd.F_ItemName = px.pxmc
WHERE kd.F_kdpxid IS NOT NULL
    AND px.pxmc IS NOT NULL
    AND px.pxmc != '';

-- 2. 开单科技老师业绩表：从开单品项明细表（lq_kd_pxmx）同步
UPDATE lq_kd_kjbsyj kd
INNER JOIN lq_kd_pxmx px ON px.F_Id = kd.F_kdpxid
SET kd.F_ItemName = px.pxmc
WHERE kd.F_kdpxid IS NOT NULL
    AND px.pxmc IS NOT NULL
    AND px.pxmc != '';

-- 3. 消耗健康师业绩表：从耗卡品项明细表（lq_xh_pxmx）同步
UPDATE lq_xh_jksyj xh
INNER JOIN lq_xh_pxmx px ON px.F_Id = xh.F_kdpxid
SET xh.F_ItemName = px.pxmc
WHERE xh.F_kdpxid IS NOT NULL
    AND px.pxmc IS NOT NULL
    AND px.pxmc != '';

-- 4. 消耗科技老师业绩表：从耗卡品项明细表（lq_xh_pxmx）同步
UPDATE lq_xh_kjbsyj xh
INNER JOIN lq_xh_pxmx px ON px.F_Id = xh.F_hkpxid
SET xh.F_ItemName = px.pxmc
WHERE xh.F_hkpxid IS NOT NULL
    AND px.pxmc IS NOT NULL
    AND px.pxmc != '';

-- 5. 退卡健康师业绩表：从退卡品项明细表（lq_hytk_mx）同步
UPDATE lq_hytk_jksyj tk
INNER JOIN lq_hytk_mx mx ON mx.F_Id = tk.F_CardReturn
SET tk.F_ItemName = mx.pxmc
WHERE tk.F_CardReturn IS NOT NULL
    AND mx.pxmc IS NOT NULL
    AND mx.pxmc != '';

-- 6. 退卡科技老师业绩表：从退卡品项明细表（lq_hytk_mx）同步
UPDATE lq_hytk_kjbsyj tk
INNER JOIN lq_hytk_mx mx ON mx.F_Id = tk.F_CardReturn
SET tk.F_ItemName = mx.pxmc
WHERE tk.F_CardReturn IS NOT NULL
    AND mx.pxmc IS NOT NULL
    AND mx.pxmc != '';

