我需要知道两个查询中哪个更有效。
第一个我正在使用join语句:
"Update a
set a.TemporaryStock = isnull(a.TemporaryStock,0) - 1
from InventoryMaster a
join InventoryTransTemp b on a.InventoryItemID = b.InventoryItemID
where b.InventoryTransTempID='" + aInTransID + "';";
第二个查询,我在where语句中使用select:
Update InventoryMaster
set TemporaryStock = isnull(TemporaryStock,0) - 1
where InventoryItemID = (Select top (1) InventoryItemID
from InventoryTransTemp
where InventoryTransTempID='" + aInTransID + "');
对于SQL Server,两个查询中的哪个更清楚,为什么?