Need help joining tables...

Posted by yuudachi on Stack Overflow See other posts from Stack Overflow or by yuudachi
Published on 2010-04-16T23:18:04Z Indexed on 2010/04/16 23:23 UTC
Read the original article Hit count: 317

Filed under:
|
|
|

I am a MySQL newbie, so sorry if this is a dumb question..

These are my tables.

student table:
SID (primary)
student_name
advisor (foreign key to faculty.facultyID)
requested_advisor (foreign key to faculty.facultyID)

faculty table:
facultyID (primary key)
advisor_name

I want to query a table that shows everything in the student table, but I want advisor and requested_advisor to show up as names, not the ID numbers.

so like it displays like this on the webpage:
Student Name: Jane Smith
SID: 860123456
Current Advisor: John Smith
Requested advisor: James Smith

not like this

Student Name: Jane Smith
SID: 860123456
Current Advisor: 1
Requested advisor: 2

SELECT student.student_name, SID, student_email, faculty.advisor_name
FROM student
INNER JOIN faculty ON student.advisor = faculty.facultyID;

this comes out close, but I don't know how to get the requested_advisor to show up as a name.

© Stack Overflow or respective owner

Related posts about mysql

Related posts about inner