select * from yourtable where id between 30 and 40
解决方案 »
- 今天用servlet开发web项目 用get方式提交参数后页面出现白板
- 为什么我用struts2 加入验证之后就不执行Action中的方法啊?struts2 高手请进!!!!!!!!!!
- hibernte不能执行查询问题
- 这里有甘肃省兰州的吗,我手上有个项目,需要合作开发....
- spring对hibernate session的管理方式?
- 请教关于hibernate3的2级缓存~
- jsp做一个请假系统关于数据库表的设计
- 请问有没方法用JMX监控JBOSS运行时产生的信息?
- 控制台抛出下面的异常
- 建议更改CSDN得分制度,大家来讨论一下
- Socket编程问题(一对一,不用多线程)
- 求救!数据连接池相同的配置为什么在Tomcat4.1没有问题,在Tamcat5.5.9下就不行!郁闷死我了!!
假设表明为tableA,主键为id
Oracle中这样:
select id from tableA
where id not in(select id from tableA where rownum<=30)
and id in (select id from tableA where rownum<=40)
SQLServer中,现在没有环境,无法测试,大概这样吧
select id from tableA
where id not in (select top 30 id from tableA )
and id in (select top 40 id from tableA)
select id from tableA
where id not in (select top 30 id from tableA )
and id in (select top 40 id from tableA)
THIS IS NOT RIGHT.
Because the id can be "30,31,35,37,39,40",thus you can only get six records by that SQL sentence.
But with my SQL sentence,you can get exactly ten records from database.
Sorry that I can only input Englis because I havn't a Chinese input method.
select id from tableA
where id not in(select id from tableA where rownum<=30)
and id in (select id from tableA where rownum<=40)
SQLServer中,现在没有环境,无法测试,大概这样吧
select id from tableA
where id not in (select top 30 id from tableA )
and id in (select top 40 id from tableA)这个应该可以的.
int i=0;
假设取得结果集为result
while(result.next())
{
if(i>=30)
{
if(i>40) break;
vector.add(result.getString("列名"));//Vector vector=new Vector();}
i++;
}
你试试吧,当循环到第30次开始存入vector,当大于40时退出循环
{
if(rs.next())
{
试试
select * from table where id between 30 and 40;如果没有顺序的话我觉得可以这样用
select top 40 from table
然后程序中的:
ResultSet.absolute(30);
while(ResultSet.next())
...
select top 40 * from table order by id(或者是其他的)