由于某些原因,虽然查询中引用了一个表,但根据错误,该表没有被引用。
查询:
WITH RECURSIVE temptable AS (
SELECT part_id, tracability_component1, tracability_component2, tracability_component3, tracking_id
FROM kpitr.subop_result SR
LEFT JOIN kpitr.part_produce PP ON PP.supplier_id || PP.product_id LIKE SR.tracability_component1 OR PP.supplier_id || PP.product_id LIKE SR.tracability_component2 OR PP.supplier_id || PP.product_id LIKE SR.tracability_component3
WHERE part_id LIKE '%0005001723A031T'
UNION ALL
SELECT SR2.part_id, SR2.tracability_component1, SR2.tracability_component2, SR2.tracability_component3, PP2.tracking_id
FROM kpitr.subop_result SR2, temptable
LEFT JOIN kpitr.part_produce PP2 ON PP2.supplier_id || PP2.product_id LIKE SR2.tracability_component1 OR PP2.supplier_id || PP2.product_id LIKE SR2.tracability_component2 OR PP2.supplier_id || PP2.product_id LIKE SR2.tracability_component3 OR SR2.part_id LIKE temptable.tracking_id
)
SELECT * FROM temptable
错误:
ERROR: invalid reference to FROM-clause entry for table "sr2"
LINE 9: ...uce PP2 ON PP2.supplier_id || PP2.product_id LIKE SR2.tracab...
^
HINT: There is an entry for table "sr2", but it cannot be referenced from this part of the query.
SQL state: 42P01
Character: 678
我相信我把一些东西放错了顺序,或者我错过了一些东西,但经过一些测试,它没有改变任何东西。
你能帮帮我吗?
1条答案
按热度按时间t98cgbkg1#
得到了解决方案,经过一些尝试: