我总是在drop select中使用左连接,我还不知道如何在更新时使用它。 我经常搜索,但我只看到两张桌子。我在三个或更多表更新中应用它时会感到困惑。
请检查我的查询:
public function updateUser($edit_id,$username)
{
$stmt=$this->conn->prepare("UPDATE tbl_login LEFT JOIN activity_logs ON tbl_login.username = activity_logs.activity_logs,
LEFT JOIN tbl_files ON tbl_login.username = tbl_files.file_uploader,
LEFT JOIN tbl_manfiles ON tbl_login.username = tbl_manfiles.file_uploader,
LEFT JOIN tbl_section ON tbl_login.username = tbl_section.creator,
LEFT JOIN tbl_adfiles ON tbl_login.username = tbl_adfiles.adfile_uploader
SET tbl_login.username=:username
WHERE id=:id");
$stmt->execute(array(":id"=>$edit_id, ":username"=>$username));
return $stmt;
}
答案 0 :(得分:1)
$query = "UPDATE profiledata t1 JOIN profileprivacy t2 ON (t1.uid = t2.uid)
SET t1.aboutyou = '$aboutyou', t1.quotes = '$quotes',
t2.aboutyouPrivacy = '$aboutyouPrivacy', t2.quotesPrivacy = '$quotesPrivacy'
WHERE t1.uid = '$sess_uid'";