jsp做网页,怎么进行数据库的统计 5
比如输入一个地区杭州,要出现杭州一共有几个,怎么写代码<%@pagelanguage="java"contentType="text/html;charset=utf-8...
比如输入一个地区杭州,要出现杭州一共有几个,怎么写代码
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%><%@ include file="../common/DB.jsp"%><html><head> </head><body><%String sql; if(request.getParameter("select") != null) { sql="select count(money) from project where money='2'"; System.out.println(sql); } ResultSet rs = statement.executeQuery(sql); ResultSetMetaData rmeta = rs.getMetaData(); String a=request.setAttribute("select",a); %><table width="515" border="0.5"> <tr> <td width="270">地区: <input type="text" name="textfield" id="textfield" /> </td> <td width="87"> <input type="button" name="select" id="select" value="查询"/></td> <td width="144"> </td> </tr> <tr height="20" style='font-size:9pt;color:#333333'align="left"> <td><%=request.getAttribute("select",a)%></td> </tr> </table><input type="submit" name="submit"value="返回 "onclick="window.location.href='projectSelect.jsp'"> </body></html> 展开
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%><%@ include file="../common/DB.jsp"%><html><head> </head><body><%String sql; if(request.getParameter("select") != null) { sql="select count(money) from project where money='2'"; System.out.println(sql); } ResultSet rs = statement.executeQuery(sql); ResultSetMetaData rmeta = rs.getMetaData(); String a=request.setAttribute("select",a); %><table width="515" border="0.5"> <tr> <td width="270">地区: <input type="text" name="textfield" id="textfield" /> </td> <td width="87"> <input type="button" name="select" id="select" value="查询"/></td> <td width="144"> </td> </tr> <tr height="20" style='font-size:9pt;color:#333333'align="left"> <td><%=request.getAttribute("select",a)%></td> </tr> </table><input type="submit" name="submit"value="返回 "onclick="window.location.href='projectSelect.jsp'"> </body></html> 展开
2个回答
展开全部
select count(city) from table where 条件 group by city
更多追问追答
追问
可是我哪里还错了,出来是错的,显示不出来,你可以具体点教我吗,谢谢了
追答
1、先把sql语句工具或者mysql客户端执行一下看看是不是想要的结果,如果不是修改sql到想要的数据为止
2、dibug程序看哪块有问题
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询