Inner join & outer join; is the order of tables in from important?

前端 未结 5 2006

Why is the order of tables important when combining an outer & an inner join ? the following fails with postgres:

SELECT grp.number AS number,     
              


        
5条回答
  •  轮回少年
    2020-12-13 06:16

    I don't know what is causing that behavior, if it's a bug or by design, but it should work fine if you stick with one form of join or the other.

    SELECT grp.number AS number,     
           tags.value AS tag   
    FROM groups grp
    JOIN insrel archiverel ON archiverel.dnumber = grp.number
    LEFT OUTER JOIN ownrel ownrel ON grp.number = ownrel.dnumber   
    LEFT OUTER JOIN tags tags ON tags.number = ownrel.snumber   
    WHERE archiverel.snumber = 11128188
    

    I would be interested to know more if the behavior is by design.

提交回复
热议问题