是不是
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)
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)
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);
如果存在就是有了。
还是说对于相同的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)));
关键是如何避免笛卡尔积的问题,有没有别的办法?
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) )