mysql 下这个语句替换成sqlserver2000 
ResultSet rs = stmt.executeQuery("select * from article where pid = 0 order by pdate desc limit " + startPos + "," + pageSize);startPos 和 pageSize 都是 int 类型变量 

解决方案 »

  1.   

    SQL Server:
    ResultSet rs = stmt.executeQuery("select top "+pageSize+" * from article where pid not in(select top "+startPos+" pid from article order by pdate desc) order by pdate desc");
      

  2.   


    pid 字段的意思 必须表里面字段为0 你个我试了好像不行
      

  3.   

    pid 改为 article 表的id字段
      

  4.   

    哦,我没有注意看到你的where pid = 0 
    那你表中总有ID吧?
    把所有的pid改成id就OK了!反正改成主键就OK
      

  5.   

    对,按照ls的思路就对了,mysql中用limit的显示查询范围,sql server用top实现。其实只是用法不一样
      

  6.   


    谢谢你了 可是还是不对 
    article 表中 主键 字段 id 自增  我是要查出 并根据 2个 int 类型参数 动态显示到页面上  article表中 pid = 0 的字段 如果你上面的语句pid改为id 那么表中 pid 不等于0的字段也会被查出来
    sqlserver 2000 用的不好 不知道在 select top 3 * from article where id not in(select top 3 id from article order by pdate desc) order by pdate desc 这个语句中能否 再加入判断语句 判断 查出数据 pid = 0 
    谢谢了
      

  7.   

    elect top 3 * from article where id not in(select top 3 id from article order by pdate desc) and pid=0 order by pdate desc
      

  8.   

    哎,原来pid=0是你的一个条件呀!
    select top "+pageSize+" * from article where pid=0 and id not in(select top "+startPos+" id from article where pid=0 order by pdate desc) order by pdate desc
    那你就像这样写,看是否可以。