【问题标题】:Table is disconnected from the rest of the join graph表与连接图的其余部分断开连接
【发布时间】:2021-12-18 19:21:07
【问题描述】:

对于我下面对表 1 的查询,我遇到了错误

“与连接图的其余部分断开连接。”

我过去遇到过这个问题,只是简单地重新排序了表引用以及标识符,并且已经修复了它。但是,我似乎无法以这种方式解决它。

select *
from (
  select table1.*, table2.*, table3.*, 
  row_number() over (partition by table1.date1,
        table1.PRODUCT_DESC,
        table1.PRODUCT_SUB_TYPE_CD,
        table3.TYPE_CPY,
        table3.entity order by table1.PRODUCT_DESC) as rn
    from table1, table2, table3
) x
where rn <= 3
and x.code1 = x.code2 
and x.account_key = x.code1
and table1.date1 between '01-APR-19' and '01-APR-21'
and x.PRODUCT_DESC = 'text'
and x.PRODUCT_SUB_TYPE_CD = 'text'
and  x.TYPE_CPY = 'text'
and x.entity = 'N'
order by x.PRODUCT_DESC;

*注意:我正在使用 Oracle SQL 开发人员

【问题讨论】:

  • 子查询后你没有 table1 或 tbale3 或 table2 ,它都是 x
  • 为什么不在子查询中包含连接条件(并使用 ANSI 连接语法)?当您运行查询时,您是否真的遇到了错误(x 发生了变化;尽管以 x.code = x.code 结尾可能不是您的意思),或者这只是一个 SQL Developer 警告 - 我认为是后者,所以可能是版本问题。
  • 您好,感谢您的反馈。你们都是正确的,我修复了这两件事(我更改了问题的变量名)。它当前正在运行,如果输出成功将更新。

标签: sql oracle debugging join


【解决方案1】:

首先总是你明确加入,然后:

select *
from (
  select table1.*, table2.*, table3.*, 
  row_number() over (partition by table1.date1,
        table1.PRODUCT_DESC,
        table1.PRODUCT_SUB_TYPE_CD,
        table3.TYPE_CPY,
        table3.entity order by table1.PRODUCT_DESC) as rn
    from table1
    join table2 on table1.code = table2.code -- ?
    join table3 on table3.code = table1.code -- ?
) x
where rn <= 3
and x.account_key = x.cod
and x.date1 between '01-APR-19' and '01-APR-21'
and x.PRODUCT_DESC = 'text'
and x.PRODUCT_SUB_TYPE_CD = 'text'
and x.TYPE_CPY = 'text'
and x.entity = 'N'
order by x.PRODUCT_DESC;

【讨论】:

    猜你喜欢
    • 2013-12-13
    • 2012-11-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-07-28
    • 1970-01-01
    • 2016-07-21
    • 1970-01-01
    相关资源
    最近更新 更多