T
Todd
Will the below work...first is a short desription of the
problem, and then a possible solution. It comes from
another newsgroup.....
Thank you.....
I think I understand the situation now. You've got a
field in one table that contains values like
this: (and is 14000 records).
1 milk eggs salt dripping
2 butter eggs milk salt pepper
3 beef onions garlic wine stock carrots mushrooms
bacon butter
4 lamb barley potatoes onions dripping
5 beef eggs wheat garlic oil
6 eggplant zucchini onion tomatoes
7 beef potatoes
and so on,
and a second table with a field like this (2000 records)
beef
potatoes
lamb
garlic
and you want to return every record that includes any of
these items.
I don't know any way of doing this in straight SQL. The
problem is the non-normalised field.
The best approach IMO would be to restructure the data,
replacing this
non-normalised field with records (one per parent or
ancestor) in a
related table.
If this isn't possible, I fear you'll need to use VBA
code that creates
a recordset on the second table and then iterates through
the records.
With fewer records you could use this to build up a long
SQL WHERE
clause, but with 2000 you'd probably run up against
Access's limits on
length and or complexity of SQL statements. So I expect
you'd need to
run a query 2000 times and use a temporary table to store
the primary
keys of the selected records. Something like this air
code:
Dim rsR As DAO.Recordset
Dim dbD as DAO.Database
Set dbD = CurrentDB()
Set rsR = dbD.OpenRecordset("TableTwo")
dbd.Execute "DELETE FROM TempTable;"
With rsR
Do Until .EOF
dbD.Execute "INSERT INTO TempTable (AnimalID) " _
& "SELECT AnimalID FROM TableOne WHERE " _
& "Pedigree LIKE """ & .Fields("AnimalID") _
& """;"
.MoveNext
Loop
End With
rsR.Close
Set rsR = Nothing
Set dbD = Nothing
But I'm not a SQL wizard. It may be worth posting in the
microsoft.public.access.queries newsgroup where the real
experts hang
out.
problem, and then a possible solution. It comes from
another newsgroup.....
Thank you.....
I think I understand the situation now. You've got a
field in one table that contains values like
this: (and is 14000 records).
1 milk eggs salt dripping
2 butter eggs milk salt pepper
3 beef onions garlic wine stock carrots mushrooms
bacon butter
4 lamb barley potatoes onions dripping
5 beef eggs wheat garlic oil
6 eggplant zucchini onion tomatoes
7 beef potatoes
and so on,
and a second table with a field like this (2000 records)
beef
potatoes
lamb
garlic
and you want to return every record that includes any of
these items.
I don't know any way of doing this in straight SQL. The
problem is the non-normalised field.
The best approach IMO would be to restructure the data,
replacing this
non-normalised field with records (one per parent or
ancestor) in a
related table.
If this isn't possible, I fear you'll need to use VBA
code that creates
a recordset on the second table and then iterates through
the records.
With fewer records you could use this to build up a long
SQL WHERE
clause, but with 2000 you'd probably run up against
Access's limits on
length and or complexity of SQL statements. So I expect
you'd need to
run a query 2000 times and use a temporary table to store
the primary
keys of the selected records. Something like this air
code:
Dim rsR As DAO.Recordset
Dim dbD as DAO.Database
Set dbD = CurrentDB()
Set rsR = dbD.OpenRecordset("TableTwo")
dbd.Execute "DELETE FROM TempTable;"
With rsR
Do Until .EOF
dbD.Execute "INSERT INTO TempTable (AnimalID) " _
& "SELECT AnimalID FROM TableOne WHERE " _
& "Pedigree LIKE """ & .Fields("AnimalID") _
& """;"
.MoveNext
Loop
End With
rsR.Close
Set rsR = Nothing
Set dbD = Nothing
But I'm not a SQL wizard. It may be worth posting in the
microsoft.public.access.queries newsgroup where the real
experts hang
out.