php - How to SELECT query including a junction tableGet the solution ↓↓↓
I have three tables:
student_ID Firstname Lastname
course_ID course_Name semester
enroll is the junction table instead of having the many to many relationships.
I need to create a SELECT statement that will return four columns:
course_Name from two tables after enrollment. Here in the enroll table, I can only see the which student_ID is enrolled in which course_ID by there primary key. But if I want to see what is the course name reference with specific course_ID enrolled by the specific student_ID, how should I write the query.
Actually I want to fetch the
course_name in a website to see which is students are enrolled in which
course_name not only the
course_name. That is why I think I will need to write a select query.
It will be helpful if anyone can help me with that.
This should work for mysql or sql server, you didn't say which you were using. You might want to limit it or use a where clause if you have a lot or rows.
SELECT students.studen_ID, students.Firstname, course.course_ID, course.course_Name FROM students JOIN enroll ON (enroll.student_ID = students.student_ID) JOIN course ON (course.course_ID = enroll.coruse_ID)
People are also looking for solutions of the problem: target class [commandmakecommand] does not exist.
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.