Solved

Update field using data in another table

Posted on 2015-01-02
8
122 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
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 33

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 33

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
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
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 33

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

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
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…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

770 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