Link to home
Start Free TrialLog in
Avatar of johnnyg123
johnnyg123Flag for United States of America

asked on

Use join in update query

I have 2 tables

One table is named training req which has 2 fileds

Shopnum and TrainingReqMet

Here is some sample data

Shopnum    TrainingReqMet
1                  Y
2                  Y



The other table is called shop master which has 3 fields
shopnum, dateopen, trainingreqmet

Here is some sample data

Shopnum    DateOpen                  TrainingReqMet
1                  12/01/2009                  Y
2                  12/21/2009                  N



Trying to write a query which will update the shop master table
 with the value of trainingreqmet value on Training Req table

Using sample data I would want shop master to look like the following after the query is run

Shopnum    DateOpen                  TrainingReqMet
1                  12/01/2009                  Y
2                  12/21/2009                  Y




(There is a one to one relationshiip between shopnumber on both tables)
ASKER CERTIFIED SOLUTION
Avatar of Patrick Matthews
Patrick Matthews
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial

UPDATE s
SET s.TrainingReqMet = tr.TrainingReqMet
FROM ShopMaster s 
INNER JOIN TrainingReq tr ON s.Shopnum = tr.ShopNum

Open in new window