sql列乘法错误

时间:2013-01-11 07:31:32

标签: sql multiplying

我试图在sql中执行乘法函数,但它不计算d值。 d问题是我forgt创建一个总行来存储乘法值n我不能创建一个新表或添加d行.. 这里是d代码我使用n d错误它是displayin。 做帮助。

<%
try
{
   Class.forName("com.mysql.jdbc.Driver");
   Connection conexion = DriverManager.getConnection("jdbc:mysql://localhost:3306/invent", "root", "hpdj850c");
   if (!conexion.isClosed())
   {
      Statement st = conexion.createStatement();
      ResultSet rs = st.executeQuery("select * from store");
      Statement sta = conexion.createStatement();
      ResultSet r = sta.executeQuery("select (rate*quantity) from store");

      out.println("<table class=\"twelve\"><thead><tr><th>Id</th><th>Name</th><th>Category</th><th>Rate</th><th>Quantity</th><th>Total</th></tr></thead>");
      while (rs.next() & r.next())
      {

         out.println("<tr>");
         out.println("<td>"+rs.getObject("itemno")+"</td>");
         out.println("<td>"+rs.getObject("name")+"</td>");
         out.println("<td>"+rs.getObject("category")+"</td>");
         out.println("<td>"+rs.getObject("rate")+"</td>");
         out.println("<td>"+rs.getObject("quantity")+"</td>"); 
         out.println("<td>"+r.getStatement() + "</td>");
         out.println("</tr>");

           }
      out.println("</table>");

      conexion.close();
   }
   else
      out.println("fail");
}
catch (Exception e)
{
   out.println("Exception " + e);
   e.printStackTrace();
}
%>

总:

com.mysql.jdbc.StatementImpl@3b46c4

1 个答案:

答案 0 :(得分:0)

而不是使用两个单独的查询使用单个查询来实现此

例如:

select            itemno ,
                  name ,
                  category ,
                  rate ,
                  quantity,
                  rate*quantity as total from Test