ASP读取数据
select * from a where id>=1 and id<=? and type=1 order by tdate desc
假设表A中有100条数据,我想要查询的数据为50条,且type=1,我写成:
select * from a where id>=1 and id<=50 and type=1 order by tdate desc
这样查询出了 ID为1~50范围内type=1的数据,由于id在1~50范围内有type<>1的数据,所以查询出来的数据不足50条;
如果知道type=1的第50条数据id,假设 id=70,可以写成:
select * from a where id>=1 and id<=70 and type=1 order by tdate desc
这样刚好查询出50条数据
可是不知道第50条数据的ID是多少,该怎么写?怎么来确定id<=?这个值呢