X
Xander
I’m trying to make a query that joins two tables based on attributes set by
the users.
They have an input table with 25 attributes which they can either fill out
or leave blank.
If for instance fill out 2 attributes, it should find those attributes in
the other table and make a join on all matches and additionally it should
then ignore all the blanks in the join statement, as they don’t match.
I put this in a small example:
Parts Attr_1 Attr_2 Attr_3 Attr_ etc
Part 1 QW RT ..
Part 2 DF ..
Part 3 AS DF ER ..
Example User table
Attr_1 Attr_2 Attr_3 Attr_ etc Volume
TY QW RT .. 122
DF AE RT .. 211
AS DF ER .. 222
DF DF ER .. 433
Example Data to join
In the above example for instance for Part 2 it should join both the 2nd and
the 4th row; so that the matching volumes can be linked to the part.
I’ve tried doing this by making the join on all the criteria as an OR
statement and then add a WHERE stating either is the above join or left table
attribute Is Null. However this doesn’t work .
I’ve also tried using an IIF statement after the FROM statement, but this
doesn’t seem to be allowed.
The only possible way I could think of is to do a join for every possible
combination and then UNION them all together.
However with 25 attributes every possible combination is a list which is way
too program, so I’m hoping someone knows a solution that can help me out.
the users.
They have an input table with 25 attributes which they can either fill out
or leave blank.
If for instance fill out 2 attributes, it should find those attributes in
the other table and make a join on all matches and additionally it should
then ignore all the blanks in the join statement, as they don’t match.
I put this in a small example:
Parts Attr_1 Attr_2 Attr_3 Attr_ etc
Part 1 QW RT ..
Part 2 DF ..
Part 3 AS DF ER ..
Example User table
Attr_1 Attr_2 Attr_3 Attr_ etc Volume
TY QW RT .. 122
DF AE RT .. 211
AS DF ER .. 222
DF DF ER .. 433
Example Data to join
In the above example for instance for Part 2 it should join both the 2nd and
the 4th row; so that the matching volumes can be linked to the part.
I’ve tried doing this by making the join on all the criteria as an OR
statement and then add a WHERE stating either is the above join or left table
attribute Is Null. However this doesn’t work .
I’ve also tried using an IIF statement after the FROM statement, but this
doesn’t seem to be allowed.
The only possible way I could think of is to do a join for every possible
combination and then UNION them all together.
However with 25 attributes every possible combination is a list which is way
too program, so I’m hoping someone knows a solution that can help me out.