我有3张桌子:
我打算加入这些表,以更新 tblorder表中的 totalAmount 。这是我使用MySql控制台的查询:
UPDATE o
SET o.totalAmount = p.unitprice * d.qty
FROM tblorder o INNER JOIN tblorderdetails d
on o.order_id = d.order_id
INNER JOIN tblproduct p
on p.pro_Id = d.pro_Id;
这是我得到的错误:
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual
that corresponds to your MySQL server version for the right syntax to use
near 'from tblorder o inner join tblorderdetails d
答案 0 :(得分:0)
语法不正确,应该是
UPDATE tblorder o
INNER JOIN tblorderdetails d
on o.order_id = d.order_id
INNER JOIN tblproduct p
on p.pro_Id = d.pro_Id
SET o.totalAmount = p.unitprice * d.qty ;