以下是引用lili在2005-11-11 14:24:25的发言:
select jno from
(SELECT pno,JNO from
tab1 t1 where pno in
(select pno from tab1 where sno = 'S1')
)T2 group by jno having count(JNO) = (select count(1) from tab1 where sno = 'S1')
其中:
SELECT pno,JNO from
tab1 t1 where pno in
(select pno from tab1 where sno = 'S1')
结果 t2 是
pno JNO
p1 j1
p2 j3
p2 j1
select count(1) from tab1 where sno = 'S1'
结果为
2
语句简化为
select jno
from t2
group by jno
having count(jno)=2
结果为
jno
j1
Bilicon对问题表述不清。
我想请教一下“group by jno having count(JNO) = (select count(1) from tab1 where sno = 'S1')”是不是应该用:
group by jno having count(JNO) >= (select count(1) from tab1 where sno = 'S1')
因为按照楼主所说是“至少包含”的意思。