Use join in update query

Posted on 2011-02-21
Medium Priority
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)
Question by:johnnyg123
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 93

Accepted Solution

Patrick Matthews earned 2000 total points
ID: 34945106
UPDATE ShopMaster
SET TrainingReqMet = tr.TrainingReqMet
    TrainingReq tr ON s.Shopnum = tr.ShopNum

Expert Comment

ID: 34949193

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

Open in new window


Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
What if you have to shut down the entire Citrix infrastructure for hardware maintenance, software upgrades or "the unknown"? I developed this plan for "the unknown" and hope that it helps you as well. This article explains how to properly shut down …
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
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

650 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