Share via

table join

loop 20 Reputation points
2023-06-22T09:18:07.5566667+00:00

Hello.

Now I have three student information sheets.

StudentID ClassID
1 701
2 702
3 706
4 709
5 709
6 709

ClassID Subject
706 Math
709 Science
701 Math

ClassID Subject
702 Physics
706 Geography

I need to use the first table as the main table and join the three tables. How do I do this?

SQL Server | Other
SQL Server | Other

Additional SQL Server features and topics not covered by specific categories


Answer accepted by question author

Anonymous
2023-06-22T09:21:17.9566667+00:00

Hi @loop

If I understand correctly, this simple query can do it.

select * from table1 as A left outer join table2 as B on A.ClassID = B.ClassID
                          left outer join table3 as C on C.ClassID = A.ClassID;

Best regards,

Percy Tang


If the answer is the right solution, please click "Accept Answer". If you have extra questions about this answer, please click "Comment".

Note: Please follow the steps in our Documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

Was this answer helpful?

1 person found this answer helpful.
0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.