更新连接表PHP MySQL

时间:2011-06-30 15:01:07

标签: php mysql

在MySQL中,我知道可以从两个已加入的表中进行选择,但是是否可以使用连接更新相同的两个表?或者我必须单独更新每个表吗?

1 个答案:

答案 0 :(得分:3)

是的,例如。

UPDATE table1 t1 
JOIN table2 t2
    ON t2.id = t1.id -- Your keys.
SET t1.column = '...', t2.column = '...' -- Your Updates
WHERE ... -- Your conditional