MySQL查询语句练习2

没有数据库先执行50q数据库

  1. 查询所有学生的Sname、Cno和Degree列.
    Select sname,cno ,degree from student inner join score on student.sno=scire.sno;
  2. 查询“95033”班所选课程的平均分
    Select cno,avg(degree) as avg from score where sno in(select sno from student where class=’95033’)group by cno;
  3. 查询选修“3-105”课程的成绩高于“109”号同学成绩的所有同学的记录
    Select degree from score where sno=’109’ and cno=’3-105’;
  4. 查询score中选学一门以上课程的同学中分数为非最高分成绩的记录
    Select sno from score group by sno having count(*)>1;
    Select * from score where sno in (Select sno from score group by sno havingcount(*)>1)
  5. 查询所有教师和同学的name、sex和birthday
    select sname as name,ssex as sex,sbirthday as birthday from student union select tname as name,tsex as sex,tbirthday as birthday from teacher;
  6. 查询所有“女”教师和“女”同学的name、sex和birthday
    select sname as name,ssex as sex,sbirthday as birthday from student where ssex='女' unio
  7. 查询成绩高于学号为“109”、课程号为“3-105”的成绩的所有记录
    select * from score where DEGREE>(select DEGREE from score where sno='109'and CNO='3-105');
  8. 查询和学号为108的同学同年出生的所有学生的Sno、Sname和Sbirthday列
    Select sno,sname,sbirthday from student where year(sbirthday)=(select year(sbirthday) from student where sno=108);
  9. 查询Student表中不姓“王”的同学记录
    Select * from student where sname not like '王%'
  10. 查询“张旭“教师任课的学生成绩
    Select degree from score,teacher,course where score.cno=course.cno and course.tno=teacher.tno and teacher.tname='张旭';

更多查询语句请参考MySQL查询语句集合

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值