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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Merge data for two tables

Status
Not open for further replies.
Oct 25, 2004
1
IN
I have a table with lots of data and the common data between this table and my new one is MAILID. Records in both tables have the same MAILID. Now, the first table doesn't have any address info, just the empty fields for such data. The new table has all the address data. I just want to merge the address data for each record in table 2 with the corresponding record in table 1 that has the same mail ID. I have tried update querys and they error out saying I must first complete an "inner join"?
Anyway.... I just need a quick way to merge the addresses for table 2 into the blank address fields for table 1.
Example:
Table 1 Table 2
MailID<-----same---->MailID (example DARCAR)
Address (blank)<---- Address (has data in it)
City (blank)<------- City (has data in it)

Can someone help me?
 
Update query is the way to go - but in order to make the changes in the 1st table, you have to specify which records. So, create a query joining both tables on the unique key [MAILID], and then make it an update query.

The query has to contain the fields you want to contain:
Table1.address and Table1.city

the &quot;update to&quot; value needs to contain the values you want to update to, in this case, [table2].[address] and [table2].[city] (use periods or brackets or access97 will convert the contents of the field to a string i.e. &quot;address&quot;)

Here's the sql output
UPDATE Table1 INNER JOIN table2 ON Table1.mailid = table2.mailid SET Table1.address = [table2].[address], Table1.city = [table2].[city];
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top