-1

I always use left join in drop select and I dont know yet how to use it on update. I've search a lot but I see only two tables. Im confuse when applying it in three or more table update.

Please check my query:

  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;
  }
Strawberry
  • 33,750
  • 13
  • 40
  • 57

1 Answers1

0
$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'";

update two tables at once

Strawberry
  • 33,750
  • 13
  • 40
  • 57