Perhaps it will be an simple question but, I don’t know how to achieve it simply.
I have two tables mentioned below.
TableA
ID Student1 Student2 Student1_Class Student2_Class
1 S0001 S0002 A A
2 S0001 S0003 B A
TableB
Class StudentID StudentName
A S0001 Jack
A S0002 Adam
A S0003 Lily
B S0001 Simpson
I’m expecting to get a result something like
ID Student1 Name1 Student2 Name2 Student1_Class Student2_Class
1 S0001 Jack S0002 Adam A A
2 S0001 Simpson S0003 Lily B A
How can I create a view based on these two tables to get the desired result?
You have to JOIN on both Class and STudent becuase S0001 is repeated.
However, your output is wrong because there is no A/S0001 match for ID = 2 in TableA to get “Simpson”. So assuming this is a typo, here you g0