Ade,
If I understand, create two union queries you need to have a unique value in each record. I used the Record column/field.
AdeQuni1
SELECT Record, Field1
FROM AdeTable1
UNION ALL
SELECT Record, Field2
FROM adeTable1
UNION ALL
SELECT Record, Field3
FROM adeTable1
UNION ALL
SELECT Record, Field4
FROM adeTable1
UNION ALL SELECT Record, Field5
FROM adeTable1;
and
AdeQuni2
SELECT Record, Field1
FROM AdeTable2
UNION ALL
SELECT Record, Field2
FROM adeTable2
UNION ALL
SELECT Record, Field3
FROM adeTable2;
Then create a third query with SQL of
SELECT AdeQuni1.Record, AdeTable1.Field1, AdeTable1.Field2, AdeTable1.Field3, AdeTable1.Field4, AdeTable1.Field5
FROM AdeTable1 INNER JOIN (AdeQuni2 INNER JOIN AdeQuni1 ON AdeQuni2.Field1 = AdeQuni1.Field1) ON AdeTable1.Record = AdeQuni1.Record
GROUP BY AdeQuni2.Record, AdeQuni1.Record, AdeTable1.Field1, AdeTable1.Field2, AdeTable1.Field3, AdeTable1.Field4, AdeTable1.Field5
HAVING (((Count(AdeQuni1.Field1))=3));
Duane Hookom
From: MS_Access_Professionals@yahoogroups.com <MS_Access_Professionals@yahoogroups.com> on behalf of Adeboyejo Oyenuga aoye_99@yahoo.co.uk [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com>
Sent: Monday, October 30, 2017 11:25 AM
To: MS_Access_Professionals@yahoogroups.com
Subject: Re: [MS_AccessPros] FIELD JOIN IN QUERY
Please see below.
TABLE1 | | | | | |
Record | Field1 | Field2 | Field3 | Field4 | Field5 |
1 | 1 | 29 | 40 | 41 | 48 |
2 | 7 | 18 | 19 | 32 | 48 |
3 | 6 | 24 | 32 | 48 | 50 |
4 | 1 | 9 | 15 | 19 | 25 |
5 | 4 | 21 | 34 | 36 | 37 |
6 | 23 | 29 | 37 | 45 | 50 |
7 | 13 | 17 | 19 | 26 | 36 |
8 | 4 | 17 | 23 | 27 | 30 |
9 | 9 | 11 | 13 | 27 | 33 |
10 | 3 | 16 | 23 | 32 | 39 |
TABLE2 | | | | | |
Record | Field1 | Field2 | Field3 | | |
1 | 2 | 23 | 39 | | |
2 | 3 | 16 | 32 | | |
3 | 3 | 18 | 23 | | |
4 | 3 | 39 | 44 | | |
5 | 11 | 32 | 39 | | |
| | | | | |
OUTCOME | | | | |
Record | Field1 | Field2 | Field3 | Field4 | Field5 |
10 | 3 | 16 | 23 | 32 | 39 |
| | | | | |
From: "Duane Hookom duanehookom@hotmail.com [MS_Access_Professionals]" <MS_Access_Professionals@yahoogroups.com>
To: "MS_Access_Professionals@yahoogroups.com" <MS_Access_Professionals@yahoogroups.com>
Sent: Monday, 30 October 2017, 15:31
Subject: Re: [MS_AccessPros] FIELD JOIN IN QUERY
Ade,
Again, can you provide some sample data and desired output? I think you would need to create union queries to normalize your table but I can't tell.
Regards,
Duane
From: MS_Access_Professionals@yahoogroups.com <MS_Access_Professionals@yahoogroups.com> on behalf of Adeboyejo Oyenuga aoye_99@yahoo.co.uk [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com>
Sent: Monday, October 30, 2017 9:56 AM
To: MS_Access_Professionals@yahoogroups.com
Subject: Re: [MS_AccessPros] FIELD JOIN IN QUERY
Thanks Duanne,
i am trying to solve a problem with some combinatorics element. There is no unique ID in the first table that equates to another ID in the second.
While the first table contains all the possibilities, my desired outcome is only those lines or records in the first table that have a record from the second table as a subset regardless of the order.
The challenge is how to join both tables to achieve this result when i run a query
Ade
From: "Duane Hookom duanehookom@hotmail.com [MS_Access_Professionals]" <MS_Access_Professionals@yahoogroups.com>
To: "MS_Access_Professionals@yahoogroups.com" <MS_Access_Professionals@yahoogroups.com>
Sent: Monday, 30 October 2017, 14:38
Subject: Re: [MS_AccessPros] FIELD JOIN IN QUERY
Ade,
It seems your tables aren't normalized correctly. Can you provide more information about what types of values you are storing? I am picturing something like storing EmployeeIDs (40 different employees) in any of the fields with headings/field names that equate to positions or roles. If this is somewhat like you system, rather than 5 fields, there should be 5 records.
How would you join? Can you provide some sample records and desired output?
Regards,
Duane Hookom
From: MS_Access_Professionals@yahoogroups.com <MS_Access_Professionals@yahoogroups.com> on behalf of Adeboyejo Oyenuga aoye_99@yahoo.co.uk [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com>
Sent: Monday, October 30, 2017 6:02 AM
To: ms_access_professionals@yahoogroups.com
Subject: [MS_AccessPros] FIELD JOIN IN QUERY
I am looking for help to create a join between two tables. Fields 1-5 in the first table can take on about 40 different unique values, while Fields 1-3 in the second table can also take on the same number of unique values. Fields 1 to 3 can each equate to any of the values in Fields 1-5 in the 1st table.
Thanks.
Ade
TABLE1 | | | | |
| | | | |
FIELD1 | FIELD2 | FIELD3 | FIELD4 | FIELD5 |
| | | | |
| | | | |
| | | | |
TABLE2 | | | | |
| | | | |
FIELD1 | FIELD2 | FIELD3 | | |
| | | | |