数据库的,要查找选修某课程的女学生姓名为什么涉及到了SC表

数据库的,要查找选修某课程的女学生姓名为什么涉及到了SC表,第1张

因为S表和C表两者并没关系,而SC表既关联S表也关联C表,所以要查女生选修了某课必须用SC表。

按你所说的,语句应该为:

select ssname from s,c,sc where ssno=scsno and ccno=sccno and asex='女' and ccname='XXXX课'

getRowCount()方法是DefaultTableModel类的方法。先创建该类对象:DefaultTableModel dtm = new DefaultTableModel();再创建一个表对象,并把DefaultTableModel加到表中:JTable tb = new JTable(dtm);然后从得到的结果集里把记录加到dtm中,int i = 1;while(scnext()){tbsetValueAt(scgetString(1),i++,1); },然后dtmgetRowCount();的到所有记录的个数。其实那个i值最后就是行数了。不知道我说是不是你想要的~~~

Student 学生表

Course 课程

SC 成绩表

Teacher 教师表

问题:

1、查询“001”课程比“002”课程成绩高的所有学生的学号

selectaS# froma, b

where ascorebscore and as#=bs#;

2、查询平均成绩大于60分的同学的学号和平均成绩;

selectS#,avg

from sc

group by S# having avg 60;

3、查询所有同学的学号、姓名、选课数、总成绩;

selectStudentS#,StudentSname,count,sum

from Student left Outer join SC on StudentS#=SCS#

group by StudentS#,Sname

4、查询姓“李”的老师的个数;

selectcount)

from Teacher

where Tname like ‘李%‘;

5、查询没学过“叶平”老师课的同学的学号、姓名;

selectStudentS#,StudentSname

from Student

where S# not infrom SC,Course,Teacher where SCC#=CourseC# and TeacherT#=CourseT# and TeacherTname=‘叶平‘);

6、查询学过“001”并且也学过编号“002”课程的同学的学号、姓名;

selectStudentS#,StudentSname from Student,SC where StudentS#=SCS# and SCC#=‘001‘and exists;

7、查询学过“叶平”老师所教的所有课的同学的学号、姓名;

selectS#,Sname

from Student

where S# in = from Course,Teacher where TeacherT#=CourseT# and Tname=‘叶平‘));

8、查询课程编号“002”的成绩比课程编号“001”课程低的所有同学的学号、姓名;

selectS#,Sname fromscore2

from Student,SC where StudentS#=SCS# and C#=‘001‘) S_2 where score2 score;

9、查询所有课程成绩小于60分的同学的学号、姓名;

selectS#,Sname

from Student

where S# not in ;

10、查询没有学全所有课的同学的学号、姓名;

selectStudentS#,StudentSname

from Student,SC

where StudentS#=SCS# group by StudentS#,StudentSname having count from Course);

SELECT studentSID,studentSname

FROM student LEFT JOIN sc

ON studentSID = scSID

WHERE scCID IS NULL;

SID为学生学号,Sname为学生姓名,CID为课程编号。

以上就是关于数据库的,要查找选修某课程的女学生姓名为什么涉及到了SC表全部的内容,包括:数据库的,要查找选修某课程的女学生姓名为什么涉及到了SC表、Jsp 我用<sql:query>标签查询数据库。结果放在变量名为sc的对象中,我想调用getRowCount()方法。、sql2005数据库查询语句等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/sjk/9547902.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-29
下一篇 2023-04-29

发表评论

登录后才能评论

评论列表(0条)

保存