Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Update Statement

Author  Topic 

Mibble
Starting Member

2 Posts

Posted - 2006-11-14 : 13:53:43
Hello,
I am very new to SQL, and am learning how to update tables.
I have one table which has for fields:
PKInventoryID, PartNumber, ProductName, QuantityOnHand, UnitPrice.

What I am wanting to do, is update two PKInventoryID items, changing the QuantityOnHand by the amount ordered.

ie; PKInventoryId # 26 has QuantityOnHand of 23 and 3 items were ordered.
PKInventoryID # 13 has QuantityOnHand of 28 and 10 were ordered.

What is the proper syntax for selecting and updating the records?

Thanks!

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-11-14 : 13:56:39
UPDATE OneTable
SET QuantityOnHand = QuantityOnHand - 3
WHERE PKInventoryId = 26

UPDATE OneTable
SET QuantityOnHand = QuantityOnHand - 10
WHERE PKInventoryId = 13


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

Mibble
Starting Member

2 Posts

Posted - 2006-11-15 : 14:58:26
thanks, that worked!
Go to Top of Page
   

- Advertisement -