Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 59107
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T17:57:12+00:00 2026-05-10T17:57:12+00:00

Why is the order of tables important when combining an outer & an inner

  • 0

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

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

with result:

ERROR:  invalid reference to FROM-clause entry for table 'grp' LINE 5: LEFT OUTER JOIN ownrel ownrel ON grp.number = ownrel.d...  ^ HINT:  There is an entry for table 'grp', but it cannot be referenced from this part of the query. 

when the groups are reversed in the FROM it all works:

SELECT  grp.number AS number,              tags.value AS tag    FROM    insrel archiverel,         groups grp LEFT OUTER JOIN ownrel ownrel ON grp.number = ownrel.dnumber    LEFT OUTER JOIN tags tags ON tags.number = ownrel.snumber    WHERE   archiverel.snumber = 11128188 AND             archiverel.dnumber = grp.number  
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T17:57:12+00:00Added an answer on May 10, 2026 at 5:57 pm

    I believe that you can think of this as an operator precedence issue.

    When you write this:

    FROM groups grp,      insrel archiverel   LEFT OUTER JOIN ownrel ownrel ON grp.number = ownrel.dnumber    LEFT OUTER JOIN tags tags ON tags.number = ownrel.snumber    

    I think it is interpreted by the parser like this:

    FROM groups grp, (   (      insrel archiverel        LEFT OUTER JOIN ownrel ownrel ON grp.number = ownrel.dnumber      ) LEFT OUTER JOIN tags tags ON tags.number = ownrel.snumber ) 

    If so, then in the innermost join ‘grp’ is unbound.

    When you reverse the lines with ‘groups’ and ‘insrel’, the innermost join applies to ‘groups’ and ‘ownrel’, so it works.

    Probably this would work as well:

        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 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose I have a dataset with those two immortal tables: Employee & Order Emp
SELECT p.id FROM produkty p, przyporzadkowania pr, stany_magazynowe, gk_grupy_produkty INNER JOIN sub_subkategorie ssi ON
I am working with an order system that has two tables Order and OrderLine
I need to generate a list of activity from multiple tables in order of
I have two Tables. Order - With Columns OrderID, OrderStatusID OrderStatus - With Columns
I have these tables: customer -------- customer_id int name varchar(255) order ----- order_id int
I wish to order a table: Firstly by Field1=3 Then by Field2 DESC I
In order to perform a case-sensitive search/replace on a table in a SQL Server
Say I have 2 tables: Customers and Orders. A Customer can have many Orders.
I have a table of records in mySql. I need to maintain an order

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.