Postgres对FROM子句的无效引用

问题描述

我很难在这里找到我做错了什么。

    select * from prog_log as g0,order_line as g1,logstat as g2
    inner join channel as g3 on g3.chn_serial = g0.log_chn_id

我遇到以下错误

    invalid reference to FROM-clause entry for table "g0"
    LINE 2: inner join channel as g3 on g3.chn_serial = g0.log_chn_id
                                                ^
    HINT:  There is an entry for table "g0",but it cannot be referenced from this part of the query.

根据我所读的内容,我需要对g0,g1和g2进行某种连接,但是我的数据库之间没有公共列,因此无法进行连接。

任何帮助将不胜感激。

解决方法

Postgres中的逗号比JOIN表达式绑定更弱;将FROM子句中的每个逗号更改为CROSS JOIN。参见note in the relevant section of the docs