id(主键) customer(公司名字)
1 信息公司
odd_id order_id(外键) price
1 1 1000
2 1 1000有上面这样两张表(会有更多数据),能不能用一条SQL语句查出和订单的总价格在jsp页面现实这样: ID 公司名称 订单总价格
1 信息公司 2000如果不能,有不有好的实现方法?
1 信息公司
odd_id order_id(外键) price
1 1 1000
2 1 1000有上面这样两张表(会有更多数据),能不能用一条SQL语句查出和订单的总价格在jsp页面现实这样: ID 公司名称 订单总价格
1 信息公司 2000如果不能,有不有好的实现方法?
(select sum(t2.price) sum_price from 第二张表名 t2 group by t2.order_id)试下,不是很有把握
这样看看:select t1.customer,t2.sum_price from 第一张表名
join (select sum(t2.price) sum_price,t2.id from 第二张表名 t2 group by t2.order_id) t3
on t1.id = t3.order_id或select t1.customer,t2.sum_price from 第一张表明 where t1.id=
(select sum(t2.price) sum_price,t2.order_id from 第二张表名 t2 group by t2.order_id)
id(主键) customer(公司名字)
1 信息公司
torder表
odd_id order_id(外键) price
1 1 1000
2 1 1000 select o.order_id,c.customer,sum(o.price)
from company c,torder o
where c.id = o.order_id
group by o.order_id,c.customer
<%
Integer payoffManSum=(Integer)request.getAttribute("payoffManSum");
%>总人数<%=payoffManSum %><br>