Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有没有办法在不知道更新查询中的原始值的情况下扣除某些值?
埃加兹。运算符仍然是减号 ( -)。所以:
-
UPDATE Item SET item_quantity = item_quantity - 5 WHERE ID = 1;
在 SQL Server 2008 及更高版本中,支持新的速记:
UPDATE Item SET item_quantity -= 5 WHERE ID = 1;
是的,内置命令称为-:
SELECT item_quantity - 5 FROM item WHERE ID = 1