postgresql – ERROR:对FROM子句的引用无效
发布时间:2020-12-13 16:27:26 所属栏目:百科 来源:网络整理
导读:我有以下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 f
我有以下SQL(PostgreSQL)查询:
SELECT ff.*,fp.* FROM fibra ff,fibra fp JOIN cables cp ON fp.cable_id = cp.id LEFT OUTER JOIN terceiro ced_pai ON ced_pai.id = cp.cedente_id LEFT OUTER JOIN terceiro tp ON tp.id = fp.terceiro_id JOIN cables cf ON ff.cable_id = cf.id LEFT OUTER JOIN terceiro ced_f ON ced_f.id = cf.cedente_id LEFT OUTER JOIN terceiro tf ON tf.id = ff.terceiro_id where 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: 42P01 Hint: 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? (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- c# – Git提交并推送二进制文件,但不保留历史记录
- datatable转XML
- flash – 如何使用AS3 SoundMixer.computeSpectrum找出歌曲
- dart – 如何在我的Flutter应用程序中重置基本路由 – 即弹
- ruby-on-rails – 在rake任务中的ActiveRecord :: Connecti
- Ruby中的Unicode文件名
- postgresql – Postgres group by quarter
- 如何找出未调用C#.NET程序集中的代码
- c# – 实体框架慢AddRange插入到DB
- ruby – 是否可以在rake任务中包含一个模块而不会污染全局范