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   
    
    不去掉重复数据并合并
    

      

  • 相关阅读:
    基本HAL库操作函数整理
    oled(iic协议)
    Uart串口中断收发
    博主回来啦
    博主的冒泡1
    AFO

    起床困难综合症
    费解的开关
    数独
  • 原文地址:https://www.cnblogs.com/zhaotiancheng/p/6188855.html
Copyright © 2011-2022 走看看