
家长表姓名,
家长表电话,
班级表班主任,
班级表人数
from 学生表,家长表,班级表
where 学生表学生编号=家长表学生编号
and 学生表班级编号=班级表班级编号
and 学生表姓名='小明' --这句不加可以查询全部学生
这个几乎所有数据库通用
这是一个嵌套查询的例子,先查出刘月的班级,然后通过in查询同班级的学生信息。
如:select 学号,班级,姓名 from 学生表 where 班级 in(select 班级 from 学生表 where 姓名='刘月')
select 班级,男=count(case when 性别='男' then 1 end),女=ccount(case when 性别='女' then 1 end) from table1 group by 班级 having count(case when 性别='男' then 1 end)>20 and ccount(case when 性别='女' then 1 end)>20
/显示学生姓名和不及格的次数/
select astudentname,b不及格次数 from T_Student a
join
(select studentid,count(score) 不及格次数
from T_Results
where score<60
group by studentid) b on astudentid=bstudentid
/显示学生姓名,学科名称,时间,成绩状况/
select astudentname 学生姓名
,bsciencename 学科名称
,ctestdate 时间
,成绩状况=(case when score>=85 then 'A'
when score>=70 and score<85 then 'B'
when score>=60 and score<70 then 'C'
else 'D' end)
from T_student a,T_science b,T_Results c
where astudentid=cstudentid
and bscienceid=cscienceid
SELECT
[教师姓名列名]
as
教师姓名,
[课程名称列名]
as
课程名称,
[班级编号列名]
as
班级编号
FROM
[课程信息表]
出来直接是中文的
select a学号, a姓名,a班级编号, avg(b分数) 平均分
from 学生信息表 a, 教学成绩表 b
where a学号=b学号
group by a学号, a姓名,a班级编号
order by 平均分 desc, 班级编号
以上就是关于数据库多表查询语句怎么写紧急!全部的内容,包括:数据库多表查询语句怎么写紧急!、MySQL数据库查询与刘月在同一班级的学生的学号,班级和姓名、sql查询语句 查询每个班男女人数分别大于20的班级号及男女生总数等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)