0

I am currently doing some exercises to better understand how to use MYSQL. I am trying to update a table that from the select results from two other tables. The general idea is to have the table exp_in_tamiahua being updated from the information on the query and keep a comparison of the items purchased vs the max amount of items allowed. rqsd as a foreign key that gets information from the purchase order table (rqsm) and the exp_in_tamiahua table has no connection to them

Update
    exp_in_tamiahua
Set
    exp_in_tamiahua.cantidad = Total,
    exp_in_tamiahua.ultima_actualizacion = rqsm.date
Select
  rqsd.ref,
  rqsd.det_item,
  Sum(rqsd.det_qty) As Total,
  rqsm.date
From
  rqsd Inner Join
  rqsm
    On rqsd.reqid = rqsm.reqid,
Where
  rqsd.det_item In ('ABRA-114', 'SODEXO GC') And
  rqsm.date > '2017 / 1 / 1'
Group By
  rqsd.det_item, rqsm.date 

This is my first semester working with databases so I do apologize for any horrible noob mistake but I would also appreciate it if you could point them out :). Would I be better off using the Insert function?

0 Answers0