"From is not valid at this position"这是我在mysql-Workbench中使用更新加入时遇到的语法错误



在此处输入图像描述当插入与产品相关的付款金额时,我想更新"产品"中的"已付款"列。。。

create table Product(
PID INT primary key,
Paid int not null default 0 ,
Total int not null
);

create table payment(
paymentid int primary key,
productid int not null,
amount int not null,
foreign key (productid) references product(paid)
);
(I am just using the dummy table to practice update using join)

update product 
set product.paid=(pay.amount+pr.Paid)
from-----> here I am getting error
payment pay 
inner join product  pr on
pay.productid=pr.pid;
create table product(
PID INT primary key,
Paid int not null default 0 ,
Total int not null
);

create table payment(
paymentid int primary key,
productid int not null,
amount int not null,
foreign key (productid) references product(paid)
);

UPDATE
product
INNER JOIN payment ON product.PID = payment.productid
SET
product.Paid = (product.Total+payment.amount)
WHERE
product.PID = payment.productid

我测试它现在工作正常。我希望它对你来说会很好。请告诉我。若你们仍然面临同样的问题。谢谢了解更多详细信息。https://www.mysqltutorial.org/mysql-update-join/

相关内容

  • 没有找到相关文章

最新更新