sql 三表连接查询

来源:百度知道 编辑:UC知道 时间:2024/06/05 10:38:40
我建立了三个表
student表
stuno(学号)stuname(姓名)
book表
bookno(书号)price(价格)
bookorder表
stuno(学号) bookno(书号) amount(数量)

我想查询 每个学生的学号 姓名 订数量 及应付多少钱

select student.stuno(学号),stuname(姓名),book.bookno(书号),count(amount),sum(price)as 应付
FROM student,book,bookorder
where student.stuno=bookorder.stuno,book.bookno=bookorder.bookno
group by stuno(学号)
go

select student.stuno,stuname,amount,price*amount from student,book,bookorder where student.stuno=bookorder.stuno and book.bookno=bookorder.bookno;

select s.stuno,stuname,amount,price*amount 应付款 from studnet s join bookorder bo on s.stuno=bo.stuno join book b on bo.bookno=b.bookno

select bookorder.stuno,stuname,amount,price*amount as pay from student,book,bookorder where bookorder.stuno=student.stuno and bookorder.bookno=book.bookno