Select CCourseNo CDescription SSectionID SSectionNo SStartDa

Select C.Course_No,

C.Description,

S.Section_ID,

S.Section_No,

S.Start_Date_Time,

I.Instructor_ID,

I.First_Name,

I.Last_name

from Course C

Inner Join Section S

ON c.course_no = s.course_no

Inner Join Instructor I

On S.Instructor_id = I.Instructor_ID

Order by C.Course_No, S.Section_ID

I have three tables... Course, Section and Instructor. I need information from three tables. I have to join the three tables together. Three tables means at least two join statements (see the two inner join statements?)

This query yields:

Courses that have Sections... that are assigned to Instructors.

What minor change... very minor change... would I have to make to yield:

Courses that have Sections... WHETHER OR NOT they are assigned to instructors?

Solution

Solution::

I have done smalle change like i have used left join.So that it will give results for the courses which are assigned to instructors and also give the list of courses which are not assigned to instructors.Query is given below::

Select C.Descriptionn as Course,S.Section_No as Section,S.Start_Date_Time,I.First_Name as Instructor_First_Name,I.Last_name as Instructor_Last_Name from Course C left Join Section S ON c.course_no = s.course_no

left Join Instructor I

On S.Instructor_id = I.Instructor_ID

Output:

Select C.Course_No, C.Description, S.Section_ID, S.Section_No, S.Start_Date_Time, I.Instructor_ID, I.First_Name, I.Last_name from Course C Inner Join Section S

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site