请问下 SQL SERVER 2000 
select top ? * from studygardenplot where groupinfo_ttg=? and id not in(select top ? id from studygardenplot where groupinfo_ttg=? order by fit desc) order by fit desc我用PreparedStatement
ps.setInt(1, ipage);
ps.setInt(2, ttg);
ps.setInt(3, (cpage - 1) * ipage);
ps.setInt(4, ttg);运行错误 java.sql.SQLException: 第 1 行: '@P0' 附近有语法错误。请问怎么办啊。

解决方案 »

  1.   

    select top ? * from studygardenplot where groupinfo_ttg=? and id not in(select top ? id from studygardenplot where groupinfo_ttg=? order by fit desc) order by fit desc写这个语句回车前要加个空格,试试。
      

  2.   

    ‘top ? *’这个可以这么写吗???
      

  3.   

    占位符?不能用在top后面,只能用在=后面。
    要动态设置的话可以用拼接sql的方式来设置。
    String sql = "select top "+ipage+" * from studygardenplot where groupinfo_ttg=? and id not in(select top "+((cpage - 1) * ipage)+" id from studygardenplot where groupinfo_ttg=? order by fit desc) order by fit desc";ps.setInt(1, ttg); 
    ps.setInt(2, ttg); 
      

  4.   

    预编译失败,驱动程序不支持这样的预编译(top ? *)
      

  5.   

    top ?  这个东西能这么用吗?貌似只能加到条件后面吧