Tak Tak - 3 months ago 8
SQL Question

select description from another table sql

I have two tables

A
and
B
. Table
A
has 5 columns (StudentID1,StudentID2,..MatchScore), and Table
B
has 3 columns (StudentID, StudentName,Age).

What I'm trying to do is make a sql statement to Display: StudentName1, StudentName2, MatchScore . Any advice please?

Answer

You need to JOIN B table twice to get that data like

select b1.StudentName as StudentName1,
b2.StudentName as StudentName2
from B b1
join A a on a.StudentID1 = b1.StudentID
join B b2 on a.StudentID2 = b2.StudentID
Comments