Home > Software engineering >  how to join three tables if many id pointing from one table to another table?
how to join three tables if many id pointing from one table to another table?

Time:11-13

I am confused here about joining suppose I have three tables here student table, course table, teacher table

'student' table

std_Id    std_Name    course_Id   teacher_Id 
1         Amit         3           1
2         Yogesh       1           1
3         Pravin       3           2 
4         Nilay        1           3 
5         Abhijit      2           3

'course' table

course_Id   course_Name   std_Id   teacher_Id
1           JAVA           1        3
2           C#             1        3
3           C              3        1
4           SAP            2        2
5           PYTHON         2        1
6          JAVASCRIPT      3        2

'teacher' table

teacher_Id  teacher_Name  std_Id  course_Id
1           Roy            1       1
2           John           2       1
3           Ben            1       3 
4           Renu           2       3
5           Ramesh         1       3

Here I am not giving any reference key so how to join three tables I am giving query here

select Std_Name,Course_Name,Teacher_Name 
from   Student
inner join Course
        on            
  • Related