• oracle 表连接


      建表:

      

    create table STU
    (
      id   NUMBER(3),
      name VARCHAR2(10)
    );
    
    create table EXAM
    (
      eid        INTEGER ,
      id      INTEGER not null,
      coursename VARCHAR2(20) ,
      grade      FLOAT
    );
    

      

      

    insert into stu (ID, NAME)
    values (3, 'kity');
    
    insert into stu (ID, NAME)
    values (2, 'tom');
    
    insert into stu (ID, NAME)
    values (1, 'jack');
    
    insert into stu (ID, NAME)
    values (4, 'nono');
    
    insert into exam (ID, GRADE)
    values (11, 89);
    
    insert into exam (ID, GRADE)
    values (2, 76);
    
    insert into exam (ID, GRADE)
    values (1, 56);
    

      

    select stu.id, exam.id, stu.name, exam.grade from stu left join exam on stu.id = exam.id;    --左连接
    select stu.id, exam.id, stu.name, exam.grade from stu,exam where stu.id = exam.id(+);        --左链接
    select stu.id, exam.id, stu.name, exam.grade from stu,exam where stu.id(+) = exam.id;        --右链接
    

      

     

    select stu.id, exam.id, stu.name, exam.grade from stu,exam where stu.id = exam.id(+);        --左链接
    -- "+" 号在右侧,则就是左连接,查询出来的结果集就以stu的总结果数为准,而exam
    --中如果没有与stu关联上,则以空 补足,具体可以看sql语句的执行结果的截图
    select stu.id, exam.id, stu.name, exam.grade from stu,exam where stu.id(+) = exam.id;        --右链接
    -- "+" 号在左侧,则是右连接,同上。
    

      

      左连接:

      右连接:

       

  • 相关阅读:
    大数据Hadoop-2
    大数据Hadoop-1
    Consistent Hashing
    分支的创建、删除、切换、合并以及冲突解决
    windows WEB 高可用/可伸缩
    Oracle行转列、列转行的Sql语句总结
    从零到百亿互联网金融架构发展史---架构变迁
    WebJars
    springcloud(五):熔断监控Hystrix Dashboard和Turbine
    SpringBoot编写自定义的starter 专题
  • 原文地址:https://www.cnblogs.com/Sunnor/p/4550499.html
Copyright © 2020-2023  润新知