Create a query to merge records with two fields as criteria

C

chilidog

I've got 2 tables, one with company locations/addresses and another with
contacts for the company. Table 1 has an ID field for the company name and
and ID field for the location (for that specific company). Table 2 has each
contact's name with the ID fields for company name and location. For
instance, Ajax Co has ID of 1; it's NY location has ID of 3. Joe Smith works
for Ajax in NY. How do i create the query to pull on ID field first and then
on the location field?
 
J

John Spencer

If I understand you correctly you would join on two fields.

SELECT *
FROM CompanyLocationsTable INNER JOIN ContactTable
ON CompanyLocationsTable .CompanyID = ContactTable.CompanyID
AND CompanyLocationsTable .LocationID = ContactTable.LocationID

In query design view
== add both tables
== Drag from companyid to companyid (set up first part of relation)
== Drag from locationID to locationID (set up second part of relation)

John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
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