009--MySQL面试题
Paste_Image.png

1.查询Java课程的学生姓名和学号

select stu.no,stu.name 
from 
table_student stu 
inner join table_sc sc on sc.no = stu.no
inner join table_course cou on sc.number = cou.number
where upper(cou.coursename) = 'JAVA'

2.依依的选修课名称

select cou.coursename
from 
table_course cou 
inner join table_student stu on stu.number = stu.number

3.选修5门课的学生

select stu.no,stu.name 
from 
table_student stu 
inner join (select score.no,count(score.no) noCount from table_sc score GROUP BY score.no ) tempSc on tempSc.no = stu.no
where tempSc.noCount=5

4.分页查询1-5

SELECT stu.* 
FROM table_student stu 
LIMIT 0,5

5.成绩排序,五页一条,查第二页

SELECT sc.* 
FROM table_sc sc 
Order by sc.chengJi
LIMIT 5,5

6.每个班级成绩最好的学生姓名和成绩

select stu.no,stu.name 
from 
table_student stu 
where stu.no in (select sc.no from table_sc sc where sc.chengJi = Max(sc.chengJi) GROUP BY score.number)

7.取出当前时间

SELECT DATE_FORMAT(NOW(),'%Y%m%d%H%i%s') 

相关文章:

猜你喜欢
  • 2021-11-20
  • 2021-12-23
  • 2021-04-08
  • 2021-04-07
  • 2021-07-30
相关资源
相似解决方案