请问下 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' 附近有语法错误。请问怎么办啊。
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' 附近有语法错误。请问怎么办啊。
要动态设置的话可以用拼接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);