gpt4 book ai didi

sql - 从旧样式到新样式的加入

转载 作者:行者123 更新时间:2023-12-01 23:07:51 27 4
gpt4 key购买 nike

我一直在尝试将旧的 SQL 风格从交叉更改为联接,但我无法使其工作。

这是我的代码:

SELECT 'EFE' tipo,
c.empnum,
c.succlave,
d.tipopago,
d.tjcredito
FROM detcobros d,
cobros c,
masterbancos b,
monedas m
WHERE d.empnum = c.empnum
AND d.succlave = c.succlave
AND d.cobfolio = c.cobfolio
AND d.PaisClave = b.PaisClave(+)
AND d.bannum = b.bannum(+)
AND d.monNum = m.monNum
AND d.tipopago = 'EF'
AND ( (c.status IN ('AU', 'US', 'UP'))
OR ( c.status = 'CA'
AND NVL (c.cortecaja, 0) <> NVL (c.cortecajacanc, 0)))
AND c.empnum = 255
AND c.succlave = 'CDCU'
AND c.cortecaja = 3004

这是我尝试过的:

SELECT 'EFE' tipo,
c.empnum,
c.succlave,
d.tipopago,
d.tjcredito
FROM detcobros d
JOIN cobros c ON c.empnum = d.empnum
and c.succlave = d.succlave
and c.cobfolio = d.cobfolio
RIGHT JOIN masterbancos b ON b.PaisClave = d.PaisClave
and b.bannum = d.bannum
JOIN monedas m ON m.monNum = d.monNum
WHERE d.tipopago = 'EF'
AND ( (c.status IN ('AU', 'US', 'UP'))
OR ( c.status = 'CA'
AND NVL (c.cortecaja, 0) <> NVL (c.cortecajacanc, 0)))
AND c.empnum = 255
AND c.succlave = 'CDCU'
AND c.cortecaja = 3004

第一个查询返回数据,但第二个查询没有获取任何数据。

最佳答案

尝试使用 LEFT JOIN,因为 + 运算符位于右侧。

syntax + operator

关于sql - 从旧样式到新样式的加入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48447995/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com