i am trying to update two tables with one query using inner join but it's not updating or neither showing any error. here is the code
$id_prod = 2;
$id_cust = 2;
$sql5 = "UPDATE `customer`
INNER JOIN `products` ON products.cust_id=customer.id
SET prod_name = 'CAKE' AND name = 'Hassan'
WHERE id='$id_cust' AND id='id_prod' ";
$query5 = $conn->prepare($sql5);
$query5->execute(array($id_cust, $id_prod));
Maybe the column to be set is misnamed, if you prefix the column name with the table name, is that better ?
Like this :
$id_prod = 2;
$id_cust = 2;
$sql5 = "UPDATE `customer`
INNER JOIN `products` ON products.cust_id=customer.id
SET __tableName__.prod_name = 'CAKE' AND __tableName__.name = 'Hassan'
WHERE __tableName__.id='$id_cust' AND __tableName__.id='id_prod' ";
$query5 = $conn->prepare($sql5);
$query5->execute(array($id_cust, $id_prod));
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.