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)

          隨筆分類

          隨筆檔案

          文章分類

          文章檔案

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 高密市| 霍林郭勒市| 曲麻莱县| 余庆县| 贺兰县| 邳州市| 若尔盖县| 嵊泗县| 兰坪| 常山县| 张家界市| 彭阳县| 永年县| 磐石市| 昔阳县| 扬州市| 义马市| 靖边县| 永年县| 哈巴河县| 临漳县| 宜君县| 铁力市| 兴城市| 区。| 西吉县| 龙山县| 沂源县| 敦化市| 温泉县| 信宜市| 大同县| 石屏县| 广宗县| 大竹县| 大冶市| 台东县| 方山县| 南岸区| 循化| 泗水县|