Solved

Update field using data in another table

Posted on 2015-01-02
8
128 Views
Last Modified: 2015-01-02
I have a table called DEC DATA, it has a field named prodcat.  I have another table called CROSS REF and it has a field named productline that matches the field named prodcat from the DEC DATA table. The CROSS REF table also has another field called prodcat which contains the data I want to update/replace the value for prodcat on my DEC DATA TABLE when prodcat is the same as productline.
0
Comment
Question by:ector73
[X]
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
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 34

Expert Comment

by:Mike Eghtebas
ID: 40528535
Update [CROSS REF] c Set c.prodcat = (Select d.prodcat  From [DEC DATA] d Where  d.prodcat = c.productline)
0
 
LVL 18

Expert Comment

by:Simon
ID: 40528540
From your description:

UPDATE [DEC DATA]  INNER [CROSS REF]  ON [DEC DATA].prodcat=[CROSS REF].productline
SET [DEC DATA].prodcat=[CROSS REF].prodcat

Hmm.. I see that eghteas beat me to it but interpreted your requirement differently. Not sure which table you actually wanted to update.
0
 
LVL 34

Expert Comment

by:Mike Eghtebas
ID: 40528541
I think you meant this:

UPDATE [CROSS REF]  INNER [DEC DATA]  ON [DEC DATA].prodcat=[CROSS REF].productline
SET [CROSS REF].prodcat=[DEC DATA].prodcat
0
Industry Leaders: 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!

 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 40528543
try this query


update [DEC DATA] inner join [CROSS REF]
on [DEC DATA].productline = [CROSS REF].prodcat
set [DEC DATA].prodcat = [CROSS REF].prodcat
0
 

Author Comment

by:ector73
ID: 40528556
I am getting a syntax error on Join operation
0
 

Author Comment

by:ector73
ID: 40528558
If I use eghtebas solution I get a pop up screen asking for a parameter.
0
 
LVL 34

Expert Comment

by:Mike Eghtebas
ID: 40528562
UPDATE [CROSS REF]  INNER JOIN [DEC DATA]  ON [DEC DATA].prodcat=[CROSS REF].productline
SET [CROSS REF].prodcat=[DEC DATA].prodcat
0
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 500 total points
ID: 40528583
ector73

try my post at http:#a40528543
0

Featured Post

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

726 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