zoukankan      html  css  js  c++  java
  • left outer join 和 right outer join 和 join 的区别

    举个例子你就能知道了!
    A表(a1,b1,c1)      B表(a2,b2)
    a1   b1   c1       a2    b2
    01   数学 95       01    张三
    02   语文 90       02    李四
    03   英语 80       04    王五
    select A.*,B.* from A
    inner join B on(A.a1=B.a2)
    结果是:
    a1   b1   c1       a2    b2
    01   数学 95       01    张三
    02   语文 90       02    李四

    select A.*,B.* from A
    left outer join B on(A.a1=B.a2)
    结果是:
    a1   b1   c1       a2    b2
    01   数学 95       01    张三
    02   语文 90       02    李四
    03   英语 80       NULL  NULL

    select A.*,B.* from A
    right outer join B on(A.a1=B.a2)
    结果是:
    a1   b1   c1       a2    b2
    01   数学 95       01    张三
    02   语文 90       02    李四
    NULL NULL NULL     04    王五

    select A.*,B.* from A
    full outer join B on(A.a1=B.a2)
    结果是:
    a1   b1   c1       a2    b2
    01   数学 95       01    张三
    02   语文 90       02    李四
    03   英语 80       NULL  NULL
    NULL NULL NULL     04    王五

    查询明细表的最新记录不重复

    select * from (select 子Id,max(时间),max(表ID) as 表ID from 表1 group by 子ID order by desc ) as a inner join 表1 as b on a.表ID=b.表ID

  • 相关阅读:
    重构二叉树
    LeetCode-Construct Binary Tree from Preorder and Inorder Traversal
    二叉平衡树
    二叉树的三种递归与非递归遍历算法
    Jump Game
    Ubuntu中安装最新 Node.js 和 npm
    ORACLE查看并修改最大连接数
    设计模式之工厂模式
    设计模式之单例模式
    设计模式之模板方法模式
  • 原文地址:https://www.cnblogs.com/wuhuisheng/p/1827048.html
Copyright © 2011-2022 走看看