zoukankan      html  css  js  c++  java
  • Oracle数据库,join多表关联方式、union结果集合并

    join on :   多表关联

    内连接 :与其他表连接

    from 表1 t  join 表2 s  on t.字段1 =s.字段2  join 表3 n on n.字段3=t.字段1
    或
    from 表1 a ,表2 b,表3c  where a.字段=b.字段
    

      

    自连接: 与自身连接

    from 表1 t  join 表1 s  on t.字段1 =s.字段1  s.字段1=t.字段1
    

    外连接:左/右连接

    left join on     左连接   保证左边表的数据全部显示
    
    right join on    右连接  保证右边表的数据全部显示
    

      

    全连接:保证两边的表的数据全部出现

    full join on
    

      

    union:结果集合并      

    要求:前后数据的列数和字段类型要一致  

    例:

    select s.name,s.sex,t.cno from student s
    union
    select t.name,t.sex,t.cno from student t   
    
    去掉重复数据并合并
    
    
    select s.name,s.sex,t.cno from student s
    union  all
    select t.name,t.sex,t.cno from student t   
    
    不去掉重复数据并合并
    

      

  • 相关阅读:
    react学习笔记一
    获取客户端时间差
    ts
    Linux学习笔记
    vuex 基本使用
    SQL入门
    ios 中倒计时计算,时间戳为NaN
    git归纳总结
    JS原型对象
    vue笔记
  • 原文地址:https://www.cnblogs.com/zhaotiancheng/p/6188855.html
Copyright © 2011-2022 走看看