是不是
select a.* 
from tablename a,tablename b
where a.c1=b.c1 
and a.c2=b.c2
and a.c3<>b.c3
and (a.c3=b.c4 or a.c4=b.c3)

解决方案 »

  1.   

    exists(((select count(*) 
                   from table1 a,table b 
                   where a.c1 = b.c1 and a.c2 = b.c2 
                         and a.c3 = b.c3 and a.c4 = b.c4)
             - (select count(*) from table1)) > 0);
    如果存在就是有了。
      

  2.   

    你的意思应该是说,对于相同的C1,C2,有相同的C3,C4吧。
      

  3.   

    上面那个里面我的 table b 应该是 table1 b。
    还是说对于相同的C1,C2,C3和C4有可能在其他存在的区间里?exists(select count(*) from table1 a,table1 b
                           where a.c1 = b.c1 and a.c2 = b.c2
                                 and ((b.c3 between a.c3 and a.c4) 
                                     or (b.c4 between a.c3 and a.c4)));
      

  4.   

    pather_totem兄,即使日期没有重合,你的sql也会返回现有的总纪录数
    关键是如何避免笛卡尔积的问题,有没有别的办法?
      

  5.   

    select a.* 
    from tablename a,tablename b
    where a.c1=b.c1 
    and a.c2=b.c2
    and a.c3<>b.c3
    and ( (a.c3 between b.c3 and b.c4)
          or (a.c4 between b.c3 and b.c4) ) 
      

  6.   

    yeah,多谢tonytucn(我是风筝) 和panther_totem(青争岁月)的大力支持