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);

  • 相关阅读:
    获取系统环境变量
    改变系统提示信息
    获取任务栏大小
    获取系统启动后经过的时间
    获取系统版本号
    z-tree的使用
    vue学习-day05 -- 案例:名字合并(监听data数据的改变)
    vue学习-day04(路由)
    eclipse在线安装ermaster插件
    vue学习-day03(动画,组件)
  • 原文地址:https://www.cnblogs.com/DravenJH/p/14092305.html
Copyright © 2011-2022 走看看