考试成绩表exam 学生表student
1.查询所有学生信息
SELECT `name`,`code` FROM student;
2.将学生小王,学号5,添加到学生表中
INSERT INTO student (`name`,`code`) VALUES("小王",6);
3修改李四的语文成绩,成绩为85
UPDATE exam SET score=90 WHERE `code`=(SELECT `code` FROM student WHERE `code`=2 )AND `subject`="语文";
4.查询出所有学生各科成绩,显示:姓名,学号,学科,成绩,并以学号与学科排序,没有成绩的学生也要查
SELECT `name`,stu.`code`,`subject`,`score` FROM student stu LEFT JOIN exam em ON stu.`code`=em.`code` ORDER BY `code`,`subject`
5.查询各科成绩平均成绩,显示学科,平均分
SELECT `subject`,AVG(score) FROM exam GROUP BY `subject`;