I have two tables:
P
and PC
(master/detail joined by the column Id)
Table P:
Id integer
Name varchar(12)
Table PC:
Id integer
Code varchar(12)
Val number
I want to get all Names from P that satisfy the following simultaneous conditions:
have a PC with
PC.Code='A'
andVal>100
have another PC with
PC.Code='B'
andVal>80
In summary, I'm only interested in those P.Name where the details comply with both conditions. Is there a way to select without resorting to INTERSECT?
The INTERSECT query is:
Select P.Name
from P, PC
where P.Id=PC.Id
and PC.Code='A' and Val>100
INTERSECT
Select P.Name
from P, PC
where P.Id=PC.Id
and PC.Code='B' and Val>80
(The interest is to check performance and also to allow the query to be run in Access)