Oracle 左外连接

发布于 2024-07-27 17:28:24 字数 559 浏览 2 评论 0原文

SELECT
    a,
    last_note_user,
    c,
    d,
    iso_src
FROM
    X
    CROSS JOIN Y
    CROSS JOIN Z
    LEFT OUTER JOIN W
        ON W.last_note_user = Z.userid
           AND W.user_ten = Y.iso_src

上面的 ANSI 代码获取了 107 条记录,当我给出没有 ANSI 代码的相同查询时,它获取了 875 条记录。非 ANSI 查询如下:

SELECT
    a,
    last_note_user,
    c,
    d,
    iso_src
FROM
    X,
    Y,
    Z,
    W
WHERE
    W.last_note_user = Z.userid(+)
    AND W.user_ten = Y.iso_src(+)

为什么使用 ANSI 和不使用 ANSI 标准的两个查询存在差异? 通过回答上述问题,请帮助我!

SELECT
    a,
    last_note_user,
    c,
    d,
    iso_src
FROM
    X
    CROSS JOIN Y
    CROSS JOIN Z
    LEFT OUTER JOIN W
        ON W.last_note_user = Z.userid
           AND W.user_ten = Y.iso_src

The above ANSI code fetch me 107 records,When I giving the same query without ANSI code it is fetching 875 records.The non ANSI query is below:

SELECT
    a,
    last_note_user,
    c,
    d,
    iso_src
FROM
    X,
    Y,
    Z,
    W
WHERE
    W.last_note_user = Z.userid(+)
    AND W.user_ten = Y.iso_src(+)

why there is difference in the two query with ANSI and without ANSI standards??
By answering the above query please help me out!!!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

酸甜透明夹心 2024-08-03 17:28:25

您的旧式查询在谓词的错误一侧有 (+) 符号。 应该是:

SELECT
    a,
    last_note_user,
    c,
    d,
    iso_src
FROM
    X,
    Y,
    Z,
    W
WHERE
    W.last_note_user (+) = Z.userid
    AND W.user_ten (+) = Y.iso_src

但我真的不会再使用旧式语法了。

Your old-style query has the (+) symbols on the wrong side of the predicate. It should be:

SELECT
    a,
    last_note_user,
    c,
    d,
    iso_src
FROM
    X,
    Y,
    Z,
    W
WHERE
    W.last_note_user (+) = Z.userid
    AND W.user_ten (+) = Y.iso_src

But I wouldn't use the old-style syntax any more really.

诗酒趁年少 2024-08-03 17:28:25

使用旧 ANSI 语法的 OUTER JOINS 是不明确的,所以谁知道查询优化器对此有何理解。

如果第一个 SQL 生成了正确的行,请忘记 ANSI 版本并继续。

OUTER JOINS with old ANSI-syntax are ambiguous, so who knows what the query optimizer understands with this.

If the first SQL is producing the right rows, forget about the ANSI version and move on.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文