SQL 标头和详细报告的策略
我想从mysql school 表中获取所有学校,并在students 表中获取每个学校的所有学生。带有标题和总计的基于网络的报告。我可以做类似
select * from schools join Students on schoolNo = schoolNo order by schoolNo
但是这样我想我必须跟踪当前的 schoolNo 并与以前的 schoolNo 进行比较,以便为每个新的生成标题和学生总数学校。
或者,我可以对学校进行选择,并对找到的每所学校的学生进行额外选择。这更直观,但看起来效率很低。
mySQL 是否提供了更好的技术来解决这个问题,例如专业的报告工具(如水晶报告)。
谢谢
I want to get all schools from the mysql school table and get all students of each school in the students table. for a web based report with heading and totals. I could do something like
select * from schools join students on schoolNo = schoolNo order by schoolNo
Howwever this way I think I will have to keep track of current schoolNo and compare with previous schoolNo in order to generate a header and student count totals for each new school.
Alternatively I could do a Select on Schools and additional selects on students for each school found. This is more intuitive but looks very inefficient.
Does mySQL offer a better techniques fot this like specialized reporting tools like Crystal reports.
thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您想要一份包含学生人数的学校列表吗?
注意:您应该在学生表中的 schoolNo 上放置一个索引。
You want a list of schools with number of students?
NB: You should put an index on schoolNo in students table.