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

  • SEARCH
  • Home
  • 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 6363907
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:05:49+00:00 2026-05-25T00:05:49+00:00

Thanks for reading. Not really looking for a solution here, since there are a

  • 0

Thanks for reading.
Not really looking for a solution here, since there are a few ways around it. Rather, I’m looking for an explanation of why.

This has the same result for both SQL Server and MySQL, so I wouldn’t hesitate to guess that others would produce the same result.

Tables used:

CREATE TABLE dbo.galleon_rights (id NVARCHAR(35) NOT NULL PRIMARY KEY,right VARCHAR(255) NOT NULL);
CREATE TABLE dbo.galleon_groups (id NVARCHAR(35) NOT NULL PRIMARY KEY,group NVARCHAR(50) NOT NULL);
CREATE TABLE dbo.galleon_conferences (id NVARCHAR(35) NOT NULL PRIMARY KEY,name VARCHAR(255) NOT NULL);

The following query works:

SELECT g.id,c.id,r.id
FROM dbo.galleon_rights r,dbo.galleon_groups g
INNER JOIN galleon_conferences c ON c.name=g.[group]
WHERE g.[group] NOT IN ('Test1','forumsmember') AND r.[right]!='CanView';

This query does not work, and produces an error that the g.[group] column cannot be found. The only difference between the two queries is that the order of the tables in the FROM has been switched, and the table used on the INNER JOIN is now at the beginning.

SELECT g.id,c.id,r.id
FROM dbo.galleon_groups g,dbo.galleon_rights r
INNER JOIN galleon_conferences c ON c.name=g.[group]
WHERE g.[group] NOT IN ('Test1','forumsmember') AND r.[right]!='CanView';

If you do an explicit CROSS JOIN with either table in the FROM, it works. If you do a LEFT JOIN on nothing (1=1), it works.
What I would like to know is why it works when you reverse the order of the tables in the list but does not work when the table you’re joining to is the first in the list.

Any ideas?

  • 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. Editorial Team
    Editorial Team
    2026-05-25T00:05:50+00:00Added an answer on May 25, 2026 at 12:05 am

    I think it’s because SQL order of precedence in performing joins is giving you this:

    First One:

      From dbo.galleon_rights r
          Cross Join -- It's cross join since there is no predicate to limit it    
                 (dbo.galleon_groups g Join galleon_conferences c 
                         ON c.name=g.[group] )
      Where ...
    

    and for the second One:

      From dbo.galleon_groups g 
          Cross Join 
              (dbo.galleon_rights r Join galleon_conferences c 
                          ON c.name=g.[group] )
      Where ...
    

    If you apply some parentheses to control this you should be able to duplicate the behavior…

    Case 1:

     SELECT g.id,c.id,r.id  
     FROM (dbo.galleon_rights r,dbo.galleon_groups g)
          INNER JOIN galleon_conferences c 
               ON c.name=g.[group]  
     WHERE g.[group] NOT IN ('Test1','forumsmember') 
            AND r.[right]!='CanView';  
    

    or Case 2:

     SELECT g.id,c.id,r.id  
     FROM dbo.galleon_rights r, 
         (dbo.galleon_groups g
            INNER JOIN galleon_conferences c 
                 ON c.name=g.[group] )
     WHERE g.[group] NOT IN ('Test1','forumsmember') 
            AND r.[right]!='CanView';  
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Thanks for reading this. I am dynamically generating some data which includes a select
Thanks for reading this. I have markup similar to what is below. Using the
Thanks for reading this I thought I could use find(), but couldn't make it
Thanks for reading this. I would have thought it would be as simple as
Thanks in Advance for reading and answer this question. I got button in asp
I'm reading about Rails fixtures in this guide (thanks, trevorturk). It appears you define
Not looking really for a book. I have seen lots of references and links
I'm not really to up on Async controller, I'm currently reading what I can
Thanks for reading. I'm a bit new to jQuery, and am trying to make
Thanks to reading about error handling on StackOverflow , I discovered Mz-Tools. However, I

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.