MySQL關聯多表更新的操作

anningri發表於2020-09-30

單表更新:

update table1 set columns1=1,cloumns2=2 where condition1 and condition2

多表關聯更新:

# 多表更新
update table1 t1,table2 t2 set t1.columns1=1,t2.columns1=1 where t1.id=t2.id and condition1 and condition2
# 左聯更新
update table1 t1 left join table2 t2 on t1.id = t2.id set t1.columns=1,t2.columns=1 where condition1 and condition2
本作品採用《CC 協議》,轉載必須註明作者和本文連結

相關文章