Home > Backend Development > PHP Tutorial > 选课系统,统计一个学生总共选了多少学分,该怎么解决

选课系统,统计一个学生总共选了多少学分,该怎么解决

WBOY
Release: 2016-06-13 13:38:00
Original
1114 people have browsed it

选课系统,统计一个学生总共选了多少学分
已选课程表info_selected
  字段 类型
  stu_id varchar(50)
  course_id int(11)

学生表info_student
字段 类型 整理 属性 Null 默认 额外 操作
id varchar(50) gb2312_chinese_ci 否
name varchar(20) gb2312_chinese_ci 否
dept varchar(40) gb2312_chinese_ci 否
major varchar(40) gb2312_chinese_ci 否
sex char(4) gb2312_chinese_ci 否
class varchar(20) gb2312_chinese_ci 否
password varchar(50) gb2312_chinese_ci 否 e10adc3949ba59abbe56e057f20f883e

课程表info_course

字段 类型 整理 属性 Null 默认 额外 操作
id int(5) 否 auto_increment
no varchar(50) gb2312_chinese_ci 否
name varchar(50) gb2312_chinese_ci 否
teacher_id varchar(50) gb2312_chinese_ci 否
teacher_name varchar(50) gb2312_chinese_ci 否
selectedMan int(11) 是 0
capacity int(11) 是 NULL
time varchar(50) gb2312_chinese_ci 是 NULL
place varchar(50) gb2312_chinese_ci 是 NULL
credit float 是 NULL  

统计一个学生总共选了多少学分
请高手指点这个语句该怎么写?

------解决方案--------------------

SQL code
select y.stuid,sum(a.credit) from 课程表 a,学生表 s,已选课程 y where y.course_id=a.id group by y.stu_id
<br><font color="#e78608">------解决方案--------------------</font><br>2楼的少了一个关联<br>
Copy after login
SQL code

select a.name,sum(b.credit) from 学生表 a,课程表 b,选课表 c
where a.id = c.stu_id and b.id = c.course_id group by c.stu_id <div class="clear">
                 
              
              
        
            </div>
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template