数据库分页查询语句怎么写?

来源:百度知道 编辑:UC知道 时间:2024/07/06 15:27:43

select top 页大小 *
from table1
where id>
(select max (id) from
(select top ((页码-1)*页大小) id from table1 order by id) as T
)
order by id

try{
con=DriverManager.getConnection
("jdbc:microsoft:sqlServer://59.39.69.222;databaseName=sq_my26","sq_my26","aa531233");
st=con.createStatement(1004,1007);
rs=st.executeQuery("select * from wulin");
rs.afterLast();
String s="";
for(int i=0;i<500;i++){
if(rs.previous()){
s+=rs.getString(1)+"\t"+rs.getString(2)+"\t"+rs.getString(3)+"\t"+rs.getString(4)+"\t"+rs.getString(5)+"\t"+rs.getString(6)+"\t"+rs.getString(7)+"\n";
}
}
jTextArea1.setText(s);
rs.close();
st.close();
con.close();
}catch(SQLException e2){
JOptionPane.showMessageDialog(this,"123");