Comparing two tables

D

Dimitris

Hello,
I have a problem which I don't know how to solve. I have two tables. T1 and
T2. T1 has a field with phone numbers named PN1 and T2 also has a field with
phone numbers named PN2. T1 also has a field named F1. What I need is to find
out which records of T2 have the same phone number as in T1. So actually I
want to compare entries of the two phone number fields of the two tables. And
what I need is wherever the entries of both fields are the same to have the
ID number which is in a field in T2 entered in the field F1 of table 1.

So if PN2 of T2 the same with PN1 of T1, then I must enter ID of PN2 into F1
of T1.

I hope I explained it well cause English is not my main language.
If someone can help me please be a little detailed because I am a newbie.

Thank you very much
Dimitris
 
J

John Spencer

Sounds like a simple update query
BACKUP your data before you do this. If things go wrong you cannot, undo
them but will have to restore your data from the backup.

UPDATE T1 INNER JOIN T2
ON T1.PN1 = T2.PN2
SET T1.F1 = T2.ID

In Design view (query grid)
-- New query
-- Add both tables
-- Join on the phone numbers (drag from PN1 to PN2)
-- Select PN1 as a field
-- Select Query: Update from the menu
-- In Update under PN1 enter "[T2].[Id]" (no quotes)
-- Select Query: Run from the menu


--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top