简体   繁体   中英

MYSQL - Multiple table update issue

Ive read multiple answers but none seem to work for me.

I have two tables Cus_acc_details & Cus_Register:

Cus_acc_detail

1 : CustomerID
2 : Acctid
3  : CUS_Fname
4  : Cus_Lname
5  : CUS_Phone
6  : Cus_Email

Us_Register

1  : Cus_Email
2  : Cus_Password
3  : Cus_confirm_Password

I want to update all fields from Cus_acc_detail and only Cus_Email for Cus_register. I have the following :

   <?php
   $user = $_SESSION["Cus_Email"];
   if (isset($_POST['Update'])) {


  $UpdateFname = $_POST['fname'];
  $UpdateLname = $_POST['Lname'];
  $UpdateEmail = $_POST['email'];
  $UpdatePhone = $_POST['phone'];
  }

  $sql = $dbc->query("UPDATE Cus_Register r INNER JOIN Cus_acc_details d ON( r.Cus_Email = d.Cus_Email) SET CUS_Fname = ' $UpdateFname', CUS_Lname = ' $UpdateLname', CUS_Email = ' $UpdateEmail', Cus_Phone = ' $UpdatePhone' WHERE CUS_Email = '$user' ");
 header('Location: Cus_Account.php');
 ?>

The page simply just does not update, could someone possibly point out where i have gone wrong.

应该为SET两个表都指定字段CUS_Email

UPDATE Cus_Register r INNER JOIN Cus_acc_details d ON( r.Cus_Email = d.Cus_Email) SET CUS_Fname = ' $UpdateFname', CUS_Lname = ' $UpdateLname', r.CUS_Email = ' $UpdateEmail', d.CUS_Email = ' $UpdateEmail', Cus_Phone = ' $UpdatePhone' WHERE CUS_Email = '$user'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM