数据库 实现两个表的连接

来源:百度知道 编辑:UC知道 时间:2024/06/10 10:51:37
select bno,bname,btotal,bprice
from book
where bclass='计算机类'

select sum(btotal),sum(bprice)
from book
where bclass='计算机类'

我想把两个表连接起来怎么做? 谢谢,在线等

怀疑你有没有连接的必要,我认为没有,一个是分散,一个是求和
难道你想在每条select bno...的后面都加上sum(btotal),sum(bprice)... ??这样会数据冗余
非要这样的结果,有2个方法
1,select bno,bname,btotal,bprice ,
(select sum(btotal) from from book
where bclass='计算机类) as totalall ,
(select sum(bprice) from from book
where bclass='计算机类) as priceall
from book
where bclass='计算机类'
2,一起执行你那2个SQL语句,用 set rs = conn.execute(sql).nextRecordSet
得到第二条SQL就结果