Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Other Forums
 MS Access
 Need help with Update Query

Author  Topic 

sqlslick
Yak Posting Veteran

83 Posts

Posted - 2009-06-30 : 00:11:13
Hey guys,

I need help building an update query for the following scenario:

Consider the following 2 tables:

TABLE_1
CODE_NO | ACCT_TYPE
----------------------
A----------1
B----------2
C----------3
D----------4
E----------5

TABLE_2
CODE_NO | ACCT_TYPE
----------------------
A
B
C
D
E

I need an update query that will update the ACCT_TYPE column for every record in TABLE_2 based on CODE_NO and the corresponding ACCT_TYPE values from TABLE_1. Another words, I need the query to look for CODE_NO in TABLE_1 and populate the corresponding ACCT_TYPE value in TABLE_2.

Here are a few things to consider:
- The tables are NOT RELATED even though all the ACCT_NO values from TABLE_1 exist in TABLE_2. I am building a TABLE_2 from several different text files.

- I would export the data into Excel and use the VLOOKUP function but I need to update 99,049 records in TABLE_2 and unfortunately Excel has a row limit of 65,536.

- For the record, there are 2,128 different CODE_NO in TABLE_1. I used the values A-E and 1-5 for simplicity.

I hope this is clear enough.

Thanks in advanced for your help and support!!
J

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-06-30 : 02:01:32
UPDATE table_1
INNER JOIN table_2 ON table_1.code_no = table_2.code_no
SET table_2.acct_type = [table_1]![acct_type]
WHERE (([table_1]![code_no]=[table_2]![code_no]));

generated using MS access


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

sqlslick
Yak Posting Veteran

83 Posts

Posted - 2009-06-30 : 10:57:35
Thank you once again almighty Webfred!
Go to Top of Page
   

- Advertisement -