Create a query to merge records with two fields as criteria

  • Thread starter Thread starter chilidog
  • Start date Start date
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?
 
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
 
Back
Top