zoukankan      html  css  js  c++  java
  • Mysql练习#2-查询

    Mysql练习#2-查询

    查询练习

    1、查询student表的所有记录

    select * from student;

    *表示所有

    2、查询student表中所有记录的sname、ssex和class列

    select sname,ssex,class from student;

    3、查询教师所有的单位即不重复的depart列

    select distinct depart from teacher;

    distinct排重

    4、查询score表中成绩在60到80之间的所有记录

    select * from score where degree between 60 and 80;

    between..and.. 查询区间

    select * from score where degree > 60 and degree < 80;

    使用运算符

    5、查询score表中成绩为85,86或88的记录

    select * from score where degree in(85,86,88);

    6、查询student表中“95031”班或性别为“女”的同学记录

    select * from student where class = '95013' or ssex = '女';

    7、以class降序查询student表中的所有记录

    select * from student order by class desc;

    desc为降序,asc为升序(可以不写,默认为升序)

    8、以cno升序、degree降序查询score表中的所有记录

    select * from score order by cno asc,degree desc;

    9、查询“95031”班的学生人数

    select count(*) from student where class = '95031';

    10、查询score表中的最高分的学生学号和课程号(子查询或者排序)

    子查询
    select sno,cno from score where degree = (select max(degree) from score);

  • 相关阅读:
    关于文件路径的生成
    re模块小结
    logging模块知识点及应用小结
    微信小程序上传图片
    小程序图表插件
    小程序实现多图上传、预览
    微信小程序实现验证码倒计时效果
    微信小程序上传图片,视频及预览
    小程序实现星级打分
    小程序获取系统日期时间
  • 原文地址:https://www.cnblogs.com/DravenJH/p/14092305.html
Copyright © 2011-2022 走看看