你所说的包含是什么意思?若s1对应的有p1,p2 ,是不是j 对应的必须同时有p1和p2 ?
select distinct j 
from tablename t1
where not exist
( select p
  FROM tablename  t2 
  where t1.j=t2.j and t2.p  in
      (select p from tablename t3 where s=s1)  
      and t2.p not in
      (select p from tablename t4 where t4.j=t1.j)
)好象是这样,写完我都晕了!·#¥%……—*()——+

解决方案 »

  1.   

    TO: icevi(按钮工厂) 
    你晚上不睡觉?
      

  2.   

    想想还是写错了:-(
    应该是这样:
    select distinct t1.j 
    from tablename t1
    where not exist
    ( select t2.p
      FROM tablename t2 
      where t2.s=s1 and t2.p not in
          (select t3.p from tablename t3 where t3.j=t1.j)
    )
      

  3.   

    to icevi
    对了,谢谢
    我是北京理工的学生,希望和你做朋友
    留个方式吧