George Smith
George Smith

Reputation: 25

Updating record from one table with sum of current record plus another tables record

I am attempting to update a record in my table with the sum of two records from different tables. So far I have this however it doesnt appear to work.

    UPDATE StockCatalog
    SET StockCatalog.ProductQuantity = (StockCatalog.ProductQuantity + DeliveryContent.DeliveryQuantity)
    FROM StockCatalog
    INNER JOIN DeliveryContent on StockCatalog.StockID = DeliveryContent.StockID

Any help would be much appreciated. Thanks

Upvotes: 2

Views: 38

Answers (1)

Danilo Bustos
Danilo Bustos

Reputation: 1093

try this:

 UPDATE StockCatalog
 INNER JOIN DeliveryContent on StockCatalog.StockID = DeliveryContent.StockID
 SET StockCatalog.ProductQuantity = (StockCatalog.ProductQuantity +  DeliveryContent.DeliveryQuantity)

Upvotes: 1

Related Questions