MySQL Update Left Join 示例

update sys_user t1
left join (
select student_id ,count(1) as num from edu_class_record where begin_time > '2023-09-22 00:00:00' and classification = 2
GROUP BY student_id
) t2 on t1.user_id = t2.student_id
set t1.teacher_time = t1.teacher_time - t2.num 
where t2.num > 0

 

posted on 2023-09-27 04:27  //君莫笑  阅读(171)  评论(0)    收藏  举报

导航