一个表tbl
字段 a b c
1 1 a
1 2 b
1 3 c
1 4 d
2 1 f
2 2 g
2 3 h
2 4 j
现知道c字段的两个值z1,z2
要求查询符合:z1对应的b字段值小于z2对应的b字段值并且a字段值相同
不知道说清楚了没有,谢谢!
---------------------------------------------------------------
select *
from mytable t1,mytable t2
where t1.c=@z1 and t2.c=@z2
and t1.b<t2.b and t1.a=t2.a
---------------------------------------------------------------
select x.* from tb1 x,tb1 y where x.c=z1 and y.c=z2 and x.b < y.b and x.a=y.a
---------------------------------------------------------------