Solved

Use join in update query

Posted on 2011-02-21
2
260 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 92

Accepted Solution

by:
Patrick Matthews earned 500 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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Suggested Solutions

Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

789 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