HomeGrowth
Technical User
I have a table1 contains a unique text field (6 char) called ‘LotNumber’ that allow user to create a record for each lot.
I have a table2 contains a text field (225 char) called ‘LotAffected’ that allow user to enter all the lot numbers that are affected by this record.
Table 1 Table 2
LotNumber Rec LotAffected
1 A 2,3,7
2 B 1,4,5
3 C 6
4 D 1,2,3,4,5
5 E 2
6
7
I try to build a query return all records that has a match in LotAffected
Query1(what I want)
LotNumber Rec LotAffected
1 B 1,4,5
1 D 1,2,3,4,5
2 A 2,3,7
2 D 1,2,3,4,5
2 E 2
3 A 2,3,7
3 D 1,2,3,4,5
4 B 1,4,5
4 D 1,2,3,4,5
5 B 1,4,5
5 D 1,2,3,4,5
6 C 6
7 A 2,3,7
I try using a sub-qry, but it only return records with exact match, how can I put a wild card for it to return all record? Can this be done in SQL or Query, or need to do it in VBA to loop through the records. Below is SQL statement from a query.
SELECT [Table2].*
FROM [Table2]
WHERE ((([Table2].[LotAffected]) In (SELECT [Table1].LotNumber FROM [Table1])));
Only 2 records returned where they have an exact match.
LotNumber Rec LotAffected
2 E 2
6 C 6
Thanks for any helps/suggestions
I have a table2 contains a text field (225 char) called ‘LotAffected’ that allow user to enter all the lot numbers that are affected by this record.
Table 1 Table 2
LotNumber Rec LotAffected
1 A 2,3,7
2 B 1,4,5
3 C 6
4 D 1,2,3,4,5
5 E 2
6
7
I try to build a query return all records that has a match in LotAffected
Query1(what I want)
LotNumber Rec LotAffected
1 B 1,4,5
1 D 1,2,3,4,5
2 A 2,3,7
2 D 1,2,3,4,5
2 E 2
3 A 2,3,7
3 D 1,2,3,4,5
4 B 1,4,5
4 D 1,2,3,4,5
5 B 1,4,5
5 D 1,2,3,4,5
6 C 6
7 A 2,3,7
I try using a sub-qry, but it only return records with exact match, how can I put a wild card for it to return all record? Can this be done in SQL or Query, or need to do it in VBA to loop through the records. Below is SQL statement from a query.
SELECT [Table2].*
FROM [Table2]
WHERE ((([Table2].[LotAffected]) In (SELECT [Table1].LotNumber FROM [Table1])));
Only 2 records returned where they have an exact match.
LotNumber Rec LotAffected
2 E 2
6 C 6
Thanks for any helps/suggestions