?
Solved

Resoving: The multi-part identifier could not be bound.

Posted on 2009-04-21
2
Medium Priority
?
1,105 Views
Last Modified: 2012-05-06
When I try to perform a JOIN on a query with multiple tables listed in the from clause I often get the error "The multi-part identifier could not be bound." Is there a specific reason for this?

thoughts?
select RSEC_ACTIVITY_SCHEDULE_DETAIL.trainee_id,
RSEC_ATTENDANCE.course_status_cd, count (traineeAbsent.attendance_id) as times_absent,
count(RSEC_ATTENDANCE.attendance_id) as total_ACTIVITYes
 
from dbo.RSEC_ACTIVITY_SCHEDULE_DETAIL,dbo.RSEC_ATTENDANCE
 
left join RSEC_ATTENDANCE traineeAbsent ON traineeAbsent.attendance_id = dbo.RSEC_ATTENDANCE.attendance_id 
    AND (traineeAbsent.status_cd='AttendanceStatus_ACTIVITYMissed' or 
         traineeAbsent.status_cd='AttendanceStatus_SickDay')
         
left join RSEC_TRAINEE  ON RSEC_TRAINEE.trainee_id = RSEC_ACTIVITY_SCHEDULE_DETAIL.trainee_id
 
 
where RSEC_ACTIVITY_SCHEDULE_DETAIL.ACTIVITY_schedule_id=33
and RSEC_ACTIVITY_SCHEDULE_DETAIL.ACTIVITY_schedule_detail_id  = RSEC_ATTENDANCE.ACTIVITY_schedule_detail_id
 
group by RSEC_ACTIVITY_SCHEDULE_DETAIL.trainee_id,RSEC_ATTENDANCE.course_status_cd

Open in new window

0
Comment
Question by:bryan_z
2 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 300 total points
ID: 24199140
yes, the reason is that you try to use a table.column in your query, although the table is not in the from/join anywhere.
in your query, I see that you mix join and non-join yntax, which is not good.
finally, I suggest you use table aliases in your query... make things easier to read#:
select sd.trainee_id
, a.course_status_cd
, count(ta.attendance_id) as times_absent
, count(a.attendance_id) as total_ACTIVITYes 
from dbo.RSEC_ACTIVITY_SCHEDULE_DETAIL sd
join dbo.RSEC_ATTENDANCE a
  on sd.ACTIVITY_schedule_detail_id  = a.ACTIVITY_schedule_detail_id
left join RSEC_ATTENDANCE ta  
  ON ta.attendance_id = a.attendance_id 
 AND ta.status_cd IN ( 'AttendanceStatus_ACTIVITYMissed', 'AttendanceStatus_SickDay')
left join RSEC_TRAINEE  t
  ON t.trainee_id = sd.trainee_id
where sd.ACTIVITY_schedule_id=33
group by sd.trainee_id
    , a.course_status_cd

Open in new window

0
 
LVL 4

Assisted Solution

by:newbieal
newbieal earned 200 total points
ID: 24199152
Here is some info that might explain the issue and provides a good solution:
http://aartemiou.blogspot.com/2009/01/multi-part-identifier-could-not-be.html

0

Featured Post

NEW Veeam Backup for Microsoft Office 365 1.5

With Office 365, it’s your data and your responsibility to protect it. NEW Veeam Backup for Microsoft Office 365 eliminates the risk of losing access to your Office 365 data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…

579 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question