Help with Derived Table

Last Post 21 Oct 2008 08:02 AM by nosepicker. 1 Replies.
AddThis - Bookmarking and Sharing Button Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
Balance
New Member
New Member

--
20 Oct 2008 09:40 PM
When I run this...

SELECT ProjectTbl.ProjectName, ProjectTbl.ProjectID, ProjectTbl.AssignedTo, ProjectTbl.DueDt, PriorityTbl.PriorityName, DerivedTbl.FName,
DerivedTbl.LName, TaskTbl.TaskID, TaskTbl.TaskName
FROM ProjectTbl INNER JOIN
PriorityTbl ON ProjectTbl.PriorityID = PriorityTbl.PriorityID LEFT OUTER JOIN
TaskTbl ON ProjectTbl.ProjectID = TaskTbl.ProjectID LEFT OUTER JOIN
(SELECT UserTbl.FName, UserTbl.LName, ProjectUserTbl.ProjectID
FROM UserTbl INNER JOIN
ProjectUserTbl ON UserTbl.UserID = ProjectUserTbl.UserID) AS DerivedTbl ON ProjectTbl.ProjectID = DerivedTbl.ProjectID
WHERE (ProjectUserTbl.ProjectID = 1439)

I get this error...

Msg 4104, Level 16, State 1, Line 1
The multi-part identifier "ProjectUserTbl.ProjectID" could not be bound.

It seems to be choking on the derived table, but I'm not sure why.
I've searched this error and made sure I'm referencing the columns by their table names, checked case sensitivity, etc.

Can someone shed some light?

TIA
nosepicker
New Member
New Member

--
21 Oct 2008 08:02 AM
Your WHERE clause of "WHERE (ProjectUserTbl.ProjectID = 1439)" is referencing "ProjectUserTbl", but that table only exists inside your derived table expression. You cannot reference it outside of the derived table expression. I'm not sure what logic you intended, but you either have to put that WHERE clause inside the derived table expression or reference it as "WHERE DerivedTbl.ProjectID = 1439".
You are not authorized to post a reply.

Acceptable Use Policy