Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copying primary key to another table

Status
Not open for further replies.

donishere

Programmer
May 7, 2002
101
Code:
[b]TABLE 1 SNIPPET[/b]
ID  BADGE       FIRST   LAST
16	408-00-0025	JOHN	GARRETT
17	408-00-0027	KEITH	WELTER
18	408-00-0028	KRIS	HUDECK

[b]TABLE 2 SNIPPET[/b]
ID  BADGE       SCORE
?   408-00-0025 85
?   408-00-0027 89
?   408-00-0025 80
?   408-00-0025 75
?   408-00-0028 93
?   408-00-0027 99
?   408-00-0027 79
?   408-00-0027 84
I am adding an ID field to both tables and making it the primary key for TABLE 1 so the two tables can have a relationship. Is there an automated way to copy the appropriate ID values for each Badge value from Table 1 to Table 2?

(btw, this is in MS Access)

Thanks a bunch.
 
UPDATE Table2 INNER JOIN Table1 ON Table2.Badge = Table1.Badge
SET Table2.ID = Table1.ID

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top