多表更新:update,join
1、多表更新:
下面我建两个表,并执行一系列sql语句,仔细观察sql执行后表中数据的变化,很容易就能理解多表联合更新的用法。
前期准备工作:
update join_teacher_class join join_teacher
on join_teacher_class.t_id=join_teacher.id
set begin_date='0000-00-00',t_name='老夫子'
where join_teacher.id=2;
1)查看join_teacher表信息:
2)查看join_teacher_class表信息:
3)查询连接两张表的信息:
更新操作:
update join_teacher_class join join_teacher
on join_teacher_class.t_id=join_teacher.id
set begin_date='0000-00-00',t_name='老夫子'
where join_teacher.id=2;
后期操作:
1)查看更新join_teacher表后的信息:
2)查看更新join_teacher_class表后的信息:
3)查看多表更新后的连接查询信息: