Thanks for reading. Easily solvable, but I'm curious about the logic behind it.
This is for the following tables (Galleon, an open-source ColdFusion forum):
Code:
CREATE TABLE galleon_groups (
id NVARCHAR(35) NOT NULL PRIMARY KEY,
group NVARCHAR(50) NOT NULL
);
CREATE TABLE galleon_rights (
id NVARCHAR(35) NOT NULL PRIMARY KEY,
right NVARCHAR(255) NOT NULL,
);
CREATE TABLE galleon_conferences (
id NVARCHAR(35) NOT NULL PRIMARY KEY,
name NVARCHAR(255) NOT NULL
);
I want to populate a table with each row from the `rights` table and each row from the `groups` table (nothing to join on) and join the row from the `conferences` table that corresponds to the `groups` table. When I run the following, it works:
Code:
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';
However, if I do this (switching the order of the tables in the FROM), it fails, throwing a "The multi-part identifier g.[group] could not be bound." error.
Code:
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';
So, basically, if you join on a table within a query with multiple tables in the FROM clause, it can't be joined on the first table in that list of the FROM clause?
Anyone have any insight on this?