我有三個表 分別是訂單表 商品表和訂單詳細表
三個表已經用外鍵連接好
我想創建一個觸發器 總價=商品價格*數量
但是我的總價欄位在訂單表 商品價格欄位在商品表 數量欄位在訂單詳細表
并且要怎樣通過id將他們聯系起來 求求大佬們!救救孩子把



我按照網上自己寫了個觸發器 可以幫我修改一下嘛

create trigger get_order_price
after update
on order_
for each row
BEGIN
update order_ set order_price=orderitem_pro_num*product_price
where order_.order_id=orderitem.order_id
end
uj5u.com熱心網友回復:
begin
update order_
set order_price=sum((select product_price from product) * (select orderitem_pro_num from orderitem))
from orderitem as oi,product as p
where oi.product_id=p.product_id
group by order_id;
end
又寫了一個 資料庫老是報我第四行有錯
uj5u.com熱心網友回復:
有大佬嗎!!
uj5u.com熱心網友回復:
還沒有人來救救我嗎
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/19843.html
標籤:MySQL
上一篇:SQL查詢問題
