Update Query Help

DeutchBose

Board Regular
Joined
Mar 22, 2004
Messages
83
So I have two tables...Table1 has a non-unique field called 'Key'....there are over 200,000 records and upwards of 50 of them may have the same key. There are a dozen or so fields in this table.

Table2 has the same 'Key' field, but here it is unique and it is followed by a 'Vendor Name' and 'Vendor Number' field. There are about 80K records.

In Table1 I need to add the fields Vendor Name and Vendor Number and match using the 'Key' field.

This should be simple, but I'm having issues with this...how would I set up this query?
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Hi, I got this to work by adding the 2 tables into a new query, Query -> Update Query, change the table join properties to include all records from Table 1 and only matching records from Table 2, add the fields you want updated from Table 1, enter [table2name].[name] and [table2name].[number] (or whatever your actual table and variable names are) into the "Update To" section of the query (under the relevant headings), save and run.

The SQL looks like this (but use your table and field names) :

UPDATE DB_Table1 LEFT JOIN DB_Table2 ON DB_Table1.Key = DB_Table2.Key SET DB_Table1.Name = [DB_Table2].[Name], DB_Table1.[Number] = [DB_Table2].[Number];

If it still doesn't work, let us know what issues you are having.

HTH, Andrew. :)
 
Upvote 0

Forum statistics

Threads
1,221,848
Messages
6,162,419
Members
451,765
Latest member
craigvan888

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top