我有两个表格:
我想获取满足以下同时条件的P中所有名称:
INTERSECT查询如下:
P
和PC
(通过列Id进行主/细节连接)。Table P:
Id integer
Name varchar(12)
Table PC:
Id integer
Code varchar(12)
Val number
我想获取满足以下同时条件的P中所有名称:
拥有一个PC,该PC.Code为'A'并且Val>100
拥有另一个PC,该PC.Code为'B'并且Val>80
INTERSECT查询如下:
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
这里的目的是检查性能并允许查询在Access中运行。