Write a query that displays the student firstname, lastname, course number, and course name
for all students taking classes – use an INNER Join. Label the output columns Student First, Student Last,
Course Number, and Course Name. You should have 7 rows.
is the question in my lab.
there are three tables students,courses,registration
I can get the names of the students that are registered in a course with
select firstname,lastname from students
inner join on registration students.studentid=registration.studentid
but when i try to get the other data the teacher wants returned from the courses table it doesnt work I tried a million things but what makes sense to me is
select firstname,lastname,coursenumber,coursename from students,courses
inner join registration on students.studentid=registration.studentid
but it gives me an error unknown column students.studentid in on clause.
You were very close, missing the joining condition between
registrationandcourses. You have an odd mix of implicit and explicitINNER JOINs. Your join intocoursesshould be anotherINNER JOINwhich is joined throughregistrationtostudents.And don’t forget your column aliases to satisfy the column output naming requirements. Use the
ASkeyword in yourSELECTlist. I’ll leave that part of the assignment for you to solve.