?
Solved

Use join in update query

Posted on 2011-02-21
2
Medium Priority
?
275 Views
Last Modified: 2012-05-11
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)
0
Comment
Question by:johnnyg123
2 Comments
 
LVL 93

Accepted Solution

by:
Patrick Matthews earned 2000 total points
ID: 34945106
UPDATE ShopMaster
SET TrainingReqMet = tr.TrainingReqMet
FROM ShopMaster s INNER JOIN
    TrainingReq tr ON s.Shopnum = tr.ShopNum
0
 
LVL 8

Expert Comment

by:rushShah
ID: 34949193

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

Open in new window

0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Ready to get certified? Check out some courses that help you prepare for third-party exams.
Microsoft Access has a limit of 255 columns in a single table; SQL Server allows tables with over 255 columns, but reading that data is not necessarily simple.  The final solution for this task involved creating a custom text parser and then reading…
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.
Suggested Courses

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question