G
Guest
I have an Access 2003 front-end (running in SQL Compatible Mode) Linked to
tables in SQL Server 2000.
I have a table (tblVolunteer_Ailment) that links volunteers (tblVolunteer)
to ailments (tlkpAilment).
iVolunteerID iAilmentID
1 1
2 1
2 2
3 2
I am trying to write 2 queries:
The first (which works) returns a list of volunteerIDs which have any of the
ailments specified:
SELECT DISTINCT tblVolunteer_Ailment.iVolunteerID
FROM tblVolunteer_Ailment
WHERE (((tblVolunteer_Ailment.iAilmentID)=Any (SELECT iAilmentID FROM
tlkpAilment WHERE iAilmentID IN (1,2))));
This returns 1,2,3
The second query should only return a list of volunteers that have all the
ailments specified.
SELECT DISTINCT tblVolunteer_Ailment.iVolunteerID
FROM tblVolunteer_Ailment
WHERE (((tblVolunteer_Ailment.iAilmentID)=All(SELECT iAilmentID FROM
tlkpAilment WHERE iAilmentID IN (1,2))));
However this returns no records. I am expecting it to return 1 record for
iVolunteerID 2
I eventually intend to build the queries programmatically, and I am using IN
because there may be numerous ailments that the user selects from a list.
Any help appreciated.
tables in SQL Server 2000.
I have a table (tblVolunteer_Ailment) that links volunteers (tblVolunteer)
to ailments (tlkpAilment).
iVolunteerID iAilmentID
1 1
2 1
2 2
3 2
I am trying to write 2 queries:
The first (which works) returns a list of volunteerIDs which have any of the
ailments specified:
SELECT DISTINCT tblVolunteer_Ailment.iVolunteerID
FROM tblVolunteer_Ailment
WHERE (((tblVolunteer_Ailment.iAilmentID)=Any (SELECT iAilmentID FROM
tlkpAilment WHERE iAilmentID IN (1,2))));
This returns 1,2,3
The second query should only return a list of volunteers that have all the
ailments specified.
SELECT DISTINCT tblVolunteer_Ailment.iVolunteerID
FROM tblVolunteer_Ailment
WHERE (((tblVolunteer_Ailment.iAilmentID)=All(SELECT iAilmentID FROM
tlkpAilment WHERE iAilmentID IN (1,2))));
However this returns no records. I am expecting it to return 1 record for
iVolunteerID 2
I eventually intend to build the queries programmatically, and I am using IN
because there may be numerous ailments that the user selects from a list.
Any help appreciated.