欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

ORACLE 左连接 left join

程序员文章站 2022-07-12 16:00:02
...

ORACLE 左连接:
1.使用(+)表示:
SELECT A.OID,
       A.VALUE,
       A.NE_TYPE_OID,
       NVL(B.STATUS, '1') STATUS,
       A.TYPE,
       A.STARTTIME START_TIME
  FROM ALARM_E A, ALARM_E_CLEAR_TIME B
 WHERE A.OID = B.ALARM_EVENT_OID(+);       

              

2.使用left join表示:
SELECT A.OID,
       A.VALUE,
       A.NE_TYPE_OID,
       NVL(B.STATUS, '1') STATUS,
       A.TYPE,
       A.START_TIME
  FROM (select OID,
               KPI_DEFINE_OID,
               ALARM_DEFINE_OID,
               ALARM_THRESHOLD_LINE_OID,
               THRESHOLD_VALUE,
               REPORT_TIME,
               SLICE_TYPE,
               VALUE,
               COLOR_LEVEL,
               COMP_TYPE,
               NE_OID,
               NE_TYPE_OID,
               TYPE,
               STARTTIME START_TIME
          from ALARM_E) A
  left join (select STATUS, ALARM_EVENT_OID, END_TIME
               from ALARM_E_CLEAR_TIME) B on A.OID = B.ALARM_EVENT_OID;

 

上面的两个左连接语句显示的结果是相同的,左连接,(+放在等号的右边)

相关标签: Oracle