how to add data?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

What would be the best way to update these data: I have a table of Contacts
with the fields:

Name
Employer
Employer ID (a unique id, and PK in the employers table; FK here)

I need to update the employers' id's in the Contacts table. Of course, each
Name in the Contacts table is unique, but there are multiple entries of any
given employer. How do I get the id# to each instance of that employer in the
Contacts table? Would an append query work?

Thanks for any help!
Christine
 
Well, no an append query won't work - append queries add new records. An update
query should work - Update queries add new information to existing records.

You have a table of Employers with the employerID and the Employer Name.

You need a query that links the Contacts table to the Employers table using the
employer name fields. The problem here will be how consistent the data entry
has been in the contacts table.

The SQL statement would look something like the following.
UPDATE Contacts INNER JOIN Employers
ON Contacts.Employer = Employers.EmployerNameField
SET Contacts.[Employer ID] = Employers.[Employer ID]

Where the names don't match you will have null in gthe Employer Id field. For
instance ABC Corp will not match ABC Corp. or ABC Corporation.
 
Back
Top