0

私は2つのテーブルProductProductInventory. FULL Join を作成し、Makeflag数量がゼロになったすべての製品を表示するクエリを作成しました。

Makeflag数量が 0 になったすべての製品の値を 1 に変更できるように、出力を操作するにはどうすればよいですか?

以下のクエリはMakeflag、数量がゼロになった製品だけでなく、実際にはすべての値に影響を与えています。

私は何を間違っているのですか...助けてください!

Use AdventureWorks2008R2

Select 
    Quantity, MakeFlag 
from Production.ProductInventory
FULL Join AdventureWorks2008R2.Production.Product
ON ProductInventory.ProductID = Product.ProductID where Quantity = 0

update AdventureWorks2008R2.Production.Product set MakeFlag = 1
4

2 に答える 2

1

これでうまくいくはずです

update AdventureWorks2008R2.Production.Product set MakeFlag = 1 
WHERE ProductID IN (
  SELECT ProductID FROM from Production.ProductInventory where Quantity = 0
)
于 2012-06-06T07:17:47.107 に答える