从oracle SQL转换为访问语法查询

时间:2016-07-15 10:40:40

标签: oracle ms-access

我正在尝试将sql oracle select转换为访问select查询。 你能解释一下这个“(+)”是什么意思吗?这就像加入?在这种情况下如何使用“not in”?

Select
lc.LOC, lc.HOME_ZONE, hz.AREA_TYPE, ld.QTY, sk.SKU

From
LOC lc, HOMEZONE hz, CONTAINER cn, LOAD ld, SKU sk

Where
lc.HOME_ZONE = hz.HOME_ZONE
and lc.LOC = cn.LOC (+)
and cn.CONT_NO = ld.CONT_NO (+)
and ld.PROD_NO = sk.PROD_NO (+)
and lc.LOC_COLOR_ZONE in ('80', '90', '95', '100')
and hz.AREA_TYPE in ('211', '231')
and hz.SECTION_NO not in ('990000');

1 个答案:

答案 0 :(得分:3)

(+)是外部联接的Oracle快捷方式;例如,以下两个查询是等效的:

SELECT *
  FROM tableA, tableB
 WHERE tableA.idA = tableB.idB(+)           

SELECT *
  FROM tableA
       LEFT OUTER JOIN tableB
         ON (tableA.idA = tableB.idB)

您的查询可以在ANSI SQL中重写,如下所示:

SELECT lc.LOC,
       lc.HOME_ZONE,
       hz.AREA_TYPE,
       ld.QTY,
       sk.SKU
  FROM LOC lc
       INNER JOIN HOMEZONE hz USING (HOME_ZONE)
       LEFT OUTER JOIN CONTAINER cn USING (LOC)
       LEFT OUTER JOIN LOAD ld USING (CONT_NO)
       LEFT OUTER JOIN SKU sk USING (PROD_NO)
 WHERE     lc.LOC_COLOR_ZONE IN ('80', '90', '95', '100')
       AND hz.AREA_TYPE IN ('211', '231')
       AND hz.SECTION_NO NOT IN ('990000');