SQL语句联表更新语句(MySql和SQlServer)MySql联表更新语句:
update table1 t1 inner join (select * from table2 where id= ?) t2
on t1.id = t2.id set t1.name= t2.name;
SqlServer联表更新语句:
update a3
set a3.state = a2.state
from table3 a3 inner join
(select t1.*, t2.test_id from table1 t1 left join table2 t2 on t1.c_id= t2.id
where t1.id= ?) a1 on a1.id = a3.id
inner join (select t1.state, t2.test_id from table1 t1 left join table2 t2 on t1.c_id = t2.id
where t1.id= ?) a2 on a2.test_id= a1.test_idsqlserver备份表语句
where a3.c_id= ?
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论