Question: 3.8 LAB - Select lesson schedule with multiple joins The database has three tables for tracking horse-riding lessons: Horse with columns: ID - primary key

3.8 LAB - Select lesson schedule with multiple joins

The database has three tables for tracking horse-riding lessons:

Horse with columns:

ID - primary key

RegisteredName

Breed

Height

BirthDate

Student with columns:

ID - primary key

FirstName

LastName

Street

City

State

Zip

Phone

EmailAddress

LessonSchedule with columns:

HorseID - partial primary key, foreign key references Horse(ID)

StudentID - foreign key references Student(ID)

LessonDateTime - partial primary key

Write a SELECT statement to create a lesson schedule for Feb 1, 2020 with the lesson date/time, student's first and last names, and the horse's registered name. Order the results in ascending order by lesson date/time, then by the horse's registered name. Make sure unassigned lesson times (student ID is NULL) appear in the results.

Hint: Perform a join on the LessonSchedule, Student, and Horse tables, matching the student IDs and horse IDs.

SELECT LessonSchedule.LessonDateTime, Horse.RegisteredName,Student.FirstName, Student.LastName FROM LessonSchedule LEFT JOIN Horse ON LessonSchedule.HorseID = Horse.ID LEFT JOIN Student ON LessonSchedule.StudentID = Student.ID WHERE LessonSchedule.LessonDateTime >= '2020-02-01' AND LessonSchedule.LessonDateTime

3.8 LAB - Select lesson schedule with multiple joins The database hasthree tables for tracking horse-riding lessons: Horse with columns: ID - primary

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!