postgresql – ERROR:对FROM子句的引用无效

postgresql – ERROR:对FROM子句的引用无效,第1张

概述我有以下SQL(PostgreSQL)查询: SELECT ff.*, fp.*FROM fibra ff, fibra fpJOIN cables cp ON fp.cable_id = cp.idLEFT OUTER JOIN terceiro ced_pai ON ced_pai.id = cp.cedente_idLEFT OUTER JOIN terceiro tp ON t 我有以下sql(Postgresql)查询:
SELECT ff.*,fp.*FROM fibra ff,fibra fpJOIN cables cp ON fp.cable_ID = cp.IDleft OUTER JOIN terceiro  ced_pai ON ced_pai.ID = cp.cedente_IDleft OUTER JOIN terceiro tp ON tp.ID = fp.terceiro_IDJOIN cables cf ON ff.cable_ID = cf.IDleft OUTER JOIN terceiro ced_f ON ced_f.ID = cf.cedente_IDleft OUTER JOIN terceiro tf ON tf.ID = ff.terceiro_IDwhere ff.fibra_pai_ID = fp.ID AND ff.cable_ID IN (8,9,10) AND fp.cable_ID IN (8,10)

但它给我这个错误:

ERROR:  invalID reference to FROM-clause entry for table "ff"liNE 8:  JOIN cables cf ON ff.cable_ID = cf.ID           ^HINT:  There is an entry for table "ff",but it cannot be referenced from this part of the query.********** Error **********ERROR: invalID reference to FROM-clause entry for table "ff"sql state: 42P01Hint: There is an entry for table "ff",but it cannot be referenced from this part of the query.Character: 261

有谁知道我做错了什么?

你正在混合隐式和显式的JOIN.这通常是令人困惑的阅读,并导致意外的评估阶段问题,正如你刚刚发现的.

你应该始终使用JOIN … ON语法无处不在;避免遗留FROM table1,table2.如果您更正您的查询以使用明确的JOIN而不是FROM纤维ff,则可以从WHERE子句中忽略ff.fibra_pai_ID = fp.ID,例如,从原始文件ff INNER JOIN fibra fp ON(ff.fibra_pai_ID = fp.ID)你应该得到预期的结果.

看到这个问题,A.H.链接到:

What’s wrong with this query?

总结

以上是内存溢出为你收集整理的postgresql – ERROR:对FROM子句的引用无效全部内容,希望文章能够帮你解决postgresql – ERROR:对FROM子句的引用无效所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://www.outofmemory.cn/sjk/1169644.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-02
下一篇 2022-06-02

发表评论

登录后才能评论

评论列表(0条)

保存