原创

MySQL-数据修复-相关方学习记录表的公司id不对

相关方-学习记录的公司id不对

SELECT ctm.container_id, ctm.course_id, ctm.member_id, cm.or_id 
FROM inp_course_task_member AS ctm 
INNER JOIN inp_contr_member AS cm ON ctm.member_id = cm.id
AND ctm.container_id = 'kemaihuagonggufenyou' AND ctm.course_id = 13
AND ctm.member_id = 12
GROUP BY ctm.container_id, ctm.course_id, ctm.member_id
ORDER BY ctm.id DESC;

-- 期望 or_id 得到4 而不是2 


-- 如果是2,就要修正
 select * from inp_user_learning_course where container_id = 'kemaihuagonggufenyou' and course_id = 13 and ur_id =  12 order by id desc;

 -- 更新 inp_user_learning_course 表

 update inp_user_learning_course c inner JOIN inp_contr_member m on m.id = c.ur_id and m.container_id  = c.container_id set c.or_id=m.or_id 


 SELECT m.* from inp_user_learning_course c inner JOIN inp_contr_member m on m.id = c.ur_id;


 ----------

SELECT ctm.container_id, ctm.course_id, ctm.member_id, cm.or_id FROM inp_course_task_member AS ctm
INNER JOIN inp_contr_member AS cm ON ctm.member_id = cm.id
 AND ctm.container_id = 'kemaihuagonggufenyou' AND ctm.course_id = 15
 AND ctm.member_id IN (35,34,33,32,31,30,29,28,27,26,25,24,23,22,21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2)
GROUP BY ctm.container_id, ctm.course_id, ctm.member_id
ORDER BY ctm.id DESC
正文到此结束
本文目录