zoukankan      html  css  js  c++  java
  • 关于sql的的数据操作

    student 字段:sno  sname  ssex  splace  syxid ;   yxinfo 字段:yxid  yxname  yxplace  yxtel

     

    要求:

    1) 查出“计算机系”的所有学生信息。

    select * from student where syxid =(select yxid from yxinfo where yxname = '计算机系');

    2) 查出“赵和堂”所在的院系信息。

    select * from yxinfo where yxid = (select syxid from student where sname = '赵和堂');

    3) 查出在“行政楼”办公的院系名称。

    select yxname from yxinfo where yxplace like '行政楼%';

    4) 查出男生女生各多少人。

    select ssex,count(*) from student group by ssex;

    5) 查出人数最多的院系信息。

    select * from yxinfo where yxid =(select syxid from student group by syxid order by count(*) desc limit 1);

    6) 查出跟“秦奕”同籍贯的所有人。

    select sname from student where splace = (select splace from student where sname = '秦奕');

    7)查出有“河北”人就读的院系信息。

    select * from yxinfo where yxid = (select syxid from student where splace = '河北');

    1. 学生成绩查询系统。

    表名 字段名 全部小写

    stu 字段:sno  sname  ssex  cno ; class表字段:cno    cname ;  score 字段:id  sno  cno  degree

     

    要求:

    1)    查询选修了 Oracle 的学生姓名;

    1)    select s.* from stu as s join score as o on s.sno=o.sno join class as c on c.cno=o.con where c.cname="Oracle";

    2)    查询 姜振国 同学选修了的课程名字;

    select name from coures where cnoc in (select cno from selclass where sno in (select sno from setudent where sname = '姜振国'));

    3)    查询只选修了1门课程的学生学号ID和姓名;

    select * from stu where sno in (select sno from score group by sno having count(*)=1);

    4)    查询选修了至少3门课程的学生信息;

    select * from stu where sno in (select sno from score group by sno having count(*)>=3);

  • 相关阅读:
    设计原则
    最小路径和--p64--动态规划
    ssm实现数据库关键信息的动态加载
    最大二叉树--p654--递归构造
    城市天际线--p807
    长url转短url--p535
    从中序与后序遍历中构造二叉树-p106--数组,二叉树遍历
    n皇后问题--p52--回溯
    Markdown(editormd)语法解析成HTML
    NFA的实现
  • 原文地址:https://www.cnblogs.com/mmore123/p/12180081.html
Copyright © 2011-2022 走看看