T
Tim
I have tblA with unique PrimaryKeyX.
Then tblB has many PrimaryKeyX matches, and for each there is a fieldY
that is either True or False.
tblB does not have a related match to every record in tblA, but every
record in tblB does relate to tblA by the PrimaryKeyX.
So, I need 2 queries. One that shows all records in tblA where the
related tblB records have ALL of their FieldY set to False, or where
there are no matches in tblB.
This works nice and quick as follows:
SELECT tblA.PrimaryKeyX
FROM tblA
WHERE False = ALL (SELECT tblB.fieldY FROM tblB WHERE
tblA.PrimaryKeyX= tblB.PrimaryKeyX)
The other thing I need is: All records in tblA where the related
records in tblB where ONE OR MORE of the FieldY are set to True.
It was suggested to me that I achieve this by changing the above as
follows (changing FALSE to TRUE, and changing ALL to SOME):
SELECT tblA.PrimaryKeyX
FROM tblA
WHERE True = Some (SELECT tblB.fieldY FROM tblB WHERE
tblA.PrimaryKeyX= tblB.PrimaryKeyX)
HOWEVER... everytime I try and run this one, Access fails and wants me
to send an error report to Microsoft and repair my database.
I've tried creating an entirely new database, setting up fresh links
to my SQL server for tables, and importing the queries from old, but
the problem persists.
I would VERY much appreciate any help. All other solutions to getting
this query take too long to run.
Then tblB has many PrimaryKeyX matches, and for each there is a fieldY
that is either True or False.
tblB does not have a related match to every record in tblA, but every
record in tblB does relate to tblA by the PrimaryKeyX.
So, I need 2 queries. One that shows all records in tblA where the
related tblB records have ALL of their FieldY set to False, or where
there are no matches in tblB.
This works nice and quick as follows:
SELECT tblA.PrimaryKeyX
FROM tblA
WHERE False = ALL (SELECT tblB.fieldY FROM tblB WHERE
tblA.PrimaryKeyX= tblB.PrimaryKeyX)
The other thing I need is: All records in tblA where the related
records in tblB where ONE OR MORE of the FieldY are set to True.
It was suggested to me that I achieve this by changing the above as
follows (changing FALSE to TRUE, and changing ALL to SOME):
SELECT tblA.PrimaryKeyX
FROM tblA
WHERE True = Some (SELECT tblB.fieldY FROM tblB WHERE
tblA.PrimaryKeyX= tblB.PrimaryKeyX)
HOWEVER... everytime I try and run this one, Access fails and wants me
to send an error report to Microsoft and repair my database.
I've tried creating an entirely new database, setting up fresh links
to my SQL server for tables, and importing the queries from old, but
the problem persists.
I would VERY much appreciate any help. All other solutions to getting
this query take too long to run.