Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Joining three tables

Author  Topic 

ymcglawn
Starting Member

4 Posts

Posted - 2009-05-27 : 14:57:09
Below is that query I wrote to provide all of the training class information and the instructor name. Now I have been asked to include the employees name which is located in the XHR_Employee table. When I try to add this data, I return no information.
Any help would be greatly appreciated.


SELECT XHR_Training.PersonId, XHR_Training.ClassId, XHR_Training.CourseId, XHR_Training.StartDate, XHR_Training.EndDate, XHR_Training.Location,XHR_TrainClass.InstructorName
FROM XHR_Training
left outer join XHR_TrainClass on XHR_TrainClass.ClassId = XHR_Training.ClassId AND XHR_TrainClass.CourseId = XHR_Training.CourseId --WHERE XHR_TrainClass.ClassId = XHR_Training.ClassId AND XHR_TrainClass.CourseId = XHR_Training.CourseId ORDER BY XHR_Training.StartDate

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2009-05-27 : 15:44:19
How do you link an Employee with a Training course? Maybe some DDL, sample data and expected output would be helpfull.
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-05-28 : 11:15:53
you need to first understand how XHR_Employee table is related to the above used tables and then join based on it.
Go to Top of Page
   

- Advertisement -