JSP 里SQL语句如何使用"与"把两个条件输出来???
Stringsql="select*fromcategorywheregrade=2and3";grade有三级,我想把2,3级的数据全部输出来,可是为什么只能输出2级的...
String sql = "select * from category where grade = 2 and 3";
grade有三级,我想把2,3级的数据全部输出来,可是为什么只能输出2级的,3的出不来
-------------------------------------------------------------------------
public List<Category> getChilds(){
List<Category>categories = new ArrayList<Category>();
Connection conn=DB.getConn();
Statement stmt = DB.getStatement(conn);
String sql = "select * from category where grade = 2 and 3";
ResultSet rs = DB.getResultSet(stmt, sql);
try{
while(rs.next()){
Category c = this.getCategoryFromRs(rs);
categories.add(c);
}
}catch(SQLException e){
e.printStackTrace();
}finally{
DB.close(conn);
DB.close(stmt);
DB.close(rs);
}
return categories;
}
-----------------------------
<%
for(int i=0;i<childs.size();i++){
Category c = childs.get(i);
%>
<a href=""><%=c.getName()%></a>
<%
}
%> 展开
grade有三级,我想把2,3级的数据全部输出来,可是为什么只能输出2级的,3的出不来
-------------------------------------------------------------------------
public List<Category> getChilds(){
List<Category>categories = new ArrayList<Category>();
Connection conn=DB.getConn();
Statement stmt = DB.getStatement(conn);
String sql = "select * from category where grade = 2 and 3";
ResultSet rs = DB.getResultSet(stmt, sql);
try{
while(rs.next()){
Category c = this.getCategoryFromRs(rs);
categories.add(c);
}
}catch(SQLException e){
e.printStackTrace();
}finally{
DB.close(conn);
DB.close(stmt);
DB.close(rs);
}
return categories;
}
-----------------------------
<%
for(int i=0;i<childs.size();i++){
Category c = childs.get(i);
%>
<a href=""><%=c.getName()%></a>
<%
}
%> 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询