情况:
一次更新5个表(表1,表2,表3,表4,表5)。 所有表都有“title_galery”和“uid_galery”列。 我需要将所有“title_galery”列更新为“新标题”,其中“uid_galery”为“555”。
Ps:列可以是空的,也可以是其他数据,因此,我只需要更新与“uid_galery”匹配的行。
我已经尝试了JOIN和INNER JOIN而没有成功。
更新
最后的尝试:
$conecta_for_003 = "UPDATE";
$conecta_for_003 .= " table1";
$conecta_for_003 .= " INNER JOIN table2 ON table2.uid_galery=table1.uid_galery";
$conecta_for_003 .= " INNER JOIN table3 ON table3.uid_galery=table1.uid_galery";
$conecta_for_003 .= " INNER JOIN table4 ON table4.uid_galery=table1.uid_galery";
$conecta_for_003 .= " SET";
$conecta_for_003 .= " table1.title_galery='New Title'";
$conecta_for_003 .= ", table2.title_galery='New Title'";
$conecta_for_003 .= ", table3.title_galery='New Title'";
$conecta_for_003 .= ", table4.title_galery='New Title'";
$conecta_for_003 .= " WHERE";
$conecta_for_003 .= " table1.uid_galery='555'";
答案 0 :(得分:0)
此尝试仅适用于2张桌子。
$conecta_for_003 = "UPDATE";
$conecta_for_003 .= " table1";
$conecta_for_003 .= ", table2";
$conecta_for_003 .= " SET";
$conecta_for_003 .= " table1.title_galery='New Title'";
$conecta_for_003 .= ", table2.title_galery='New Title'";
$conecta_for_003 .= " WHERE";
$conecta_for_003 .= " table2.uid_galery = table1.uid_galery";
$conecta_for_003 .= " AND";
$conecta_for_003 .= " table1.uid_galery='555'";
我试图改变它,但没有尝试过。