MySQL update a field using info in other table

前端 未结 1 776
挽巷
挽巷 2021-01-28 13:53

How can I make an update of this tables?:

Products table

  • IdProd [PK]
  • Description
  • Cost

Transaction

相关标签:
1条回答
  • 2021-01-28 14:26

    Use Update from JOIN syntax

    update Transactions A
    INNER JOIN Products B
    ON A.IdProd = B.IdProd
    set A.Total = A.Quantity * B.cost
    
    0 讨论(0)
提交回复
热议问题