oracle怎么實現左聯,右聯與外聯?9i以前寫法 9i以后10g 11g的寫法

          左聯:
          select a.id,a.name,b.address from a,b
          where a.id=b.id(+)
          右聯:
          select a.id,a.name,b.address from a,b
          where a.id(+)=b.id
          外聯
          SELECT a.id,a.name,b.address
          FROM a,b
          WHERE a.id = b.id(+)
          UNION

          SELECT b.id,'' name,b.address
          FROM b
          WHERE NOT EXISTS (
          SELECT * FROM a
          WHERE a.id = b.id);
          在9i以上,已經開始支持SQL99標準,所以,以上語句可以寫成:
          默認內部聯結:
          select a.id,a.name,b.address,c.subject
          from (a inner join b on a.id=b.id)
          inner join c on b.name = c.name
          where other_clause
          左聯
          select a.id,a.name,b.address
          from a left outer join b on a.id=b.id
          where other_clause
          右聯
          select a.id,a.name,b.address
          from a right outer join b on a.id=b.id
          where other_clause
          外聯
          select a.id,a.name,b.address
          from a full outer join b on a.id=b.id
          where other_clause
          or
          select a.id,a.name,b.address
          from a full outer join b using (id)
          where other_clause

          posted on 2009-07-08 10:19 MichaelLee 閱讀(2179) 評論(0)  編輯  收藏 所屬分類: oracle

          <2009年7月>
          2829301234
          567891011
          12131415161718
          19202122232425
          2627282930311
          2345678

          導航

          統計

          公告

          ====Michael Lee====
          =Java Sofware Engineer=
          =Work @ Beijing=
          ---再煩,也別忘微笑;再急,也要注意語氣;再苦,也別忘堅持;再累,也要愛自己!---
          ---低調做人,你會一次比一次穩健;高調做事,你會一次比一次優秀---
          ---成功的時候不要忘記過去;失敗的時候不要忘記還有未來---

          常用鏈接

          留言簿(2)

          隨筆分類

          隨筆檔案

          文章分類

          文章檔案

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 房产| 富裕县| 罗田县| 白银市| 天峨县| 衡南县| 同德县| 冀州市| 新邵县| 刚察县| 安平县| 日照市| 五河县| 蕲春县| 黄浦区| 封开县| 卢氏县| 曲沃县| 伊春市| 柳林县| 芒康县| 南丹县| 资溪县| 勃利县| 寻甸| 普安县| 丰镇市| 清涧县| 进贤县| 城市| 静安区| 邵阳县| 内江市| 呼玛县| 长葛市| 东方市| 桃园市| 北宁市| 和顺县| 阿克| 察隅县|