sqlStmt = sqlCon.createStatement(); strSQL sql="select * from (select rownum rno,content from (select * from table order by id) where rownum<=maxNO order by db_code) where rno >=mixNO order by id" sqlRst = sqlStmt.executeQuery(strSQL);
1.首先,(select * from table order by id ) a ,这里千万记得*前后要有空格;
2.这时已经为每条记录创建了rownum,这时以此a查询为表,select rownum rno,a.*where条件是rownum<maxnum;给此次rownum命名为rno
3.再次以上表b为查询,where 条件是rno>mixnum