2017-01-03 6 views
2

私は1:site_stock、2:item_add、3:stock_addという名前の3つのテーブルを持っています。今msアクセスクエリを実行する方法

UPDATE site_stock 
SET quantity = ((select sum(sa.quantity) from stock_add as sa where sa.item_code='J-110') + 
       (select sum(ia.quantity) from item_add as ia where ia.item_code='J-110')) 
WHERE item_code='J-110' and site_id=1; 

答えて

1
UPDATE ((site_stock inner join item_add on site_stock.item_code=item_add.item_code) left join stock_add on site_stock.item_code=stock_add.item_code) SET site_stock.quantity =(item_add.quantity + (iif(stock_add.quantity is null,0,stock_add.quantity))) WHERE item_add.item_code=site_stock.item_code and site_stock.site_id=1; 
「操作は更新可能なクエリを使用しなければならない」私はこのクエリを試してきたsite_stockその値はitem_add初期バランスとアイテムのstock_add量の合計でなければなりません更新したいが、それは私にエラーを与えます
関連する問題