I am using mysql.
I have two tables
Students:
stud_num
prof1
prof2
Prof
prof_id
first_name
last_name
Prof Id is a foreign key in the students table.
I want to get the stud_num and prof1 as first and last name and prof2 as first and last name
Here is my query that doesn’t work:
select s.stud_num, CONCAT(p.first_name, " ", p.last_name) as PROF1, CONCAT(p.first_name, " ", p.last_name) as PROF2
from students s
inner join prof p
on s.prof1 = p.prof
and s.prof2 = p.prof
This does not work. Is there an easy way to do this???
Join TWICE to the professors table, but I would suggest LEFT join in case one of the professor’s IDs is not provided