zoukankan      html  css  js  c++  java
  • mysql链接查询

    --链接查询
    --内连接
    --inner join...on
    --查询有能够对应班级的学生以及班级信息
    select * from student inner join classes on student.cls_id=classes,id;
    --按照要求显示姓名,班级
    select student.*,classes.name from student inner join classes on student.cls_id=classes,id;

    --给数据表起名字
    select s.*,c.name from student as s inner join classes as c on s.cls_id=c.id;

    --在以上查询中,将班级姓名显示在第一列
    select c.name,s.* from student as s inner join classes as c on s.cls_id=c.id;

    --查询有能够对应班级学生以及班级信息,按照班级进行排序
    select c.name,s.* from student as s inner join classes as c on s.cls_id=c.id order by c.name;

    --当同一个班级的时候,按照序号排序
    select c.name,s.* from student as s inner join classes as c on s.cls_id=c.id order by c.name,s.id;

    --左链接
    --left join...on
    --查询每个学生对应的班级信息
    --select * from student as s left join classes as c on s.cls_id=c.id;

    --查询没有对应班级信息的学生
    ----select * from student as s left join classes as c on s.cls_id=c.id having c,id is null;

  • 相关阅读:
    并发容器之CopyOnWriteArrayList
    Python os.listdir() 方法
    Python os.link() 方法
    Python os.lchown() 方法
    Python os.lchmod() 方法
    Python os.lchflags() 方法
    APP test
    jmeter 启动报错:not able to find java executable or version
    sqlserver数据库性能测试方法
    jmeter基础概念
  • 原文地址:https://www.cnblogs.com/zhongxiaoyan/p/12353269.html
Copyright © 2011-2022 走看看