user2318282
user2318282

Reputation:

sql using select and adding to a table

SELECT `pro`.`St`, `s`.`Quantity`
    FROM `s`
    LEFT JOIN `web`.`pro` ON `s`.`Pro_id` = `pro`.`ProdID`

the above query results in a table like

    st          quantity
    132             1
    11              1 

st is from one table and quantity is from another using this select statement I want to add the resulting quantity to the st row in the other table.

Basically updating the second table by adding the quantity i get from this select statement.

Upvotes: 2

Views: 48

Answers (1)

Thomas Ruiz
Thomas Ruiz

Reputation: 3661

UPDATE `web`.`pro`
SET `pro`.`st` = `pro`.`st` + `s`.`Quantity`
FROM `web`.`pro`
JOIN `shopping cart` `s`
  ON `s`.`Pro_id` = `pro`.`ProdID`;

Something like that ?

Upvotes: 1

Related Questions