I have the following tables.
Highschooler
Friends
And ID1 and ID2 are IDs (they are not the same) in the ID column of Highschooler. How can I select grades for both of these columns so I have something like:
ID1 Grade ID2 Grade
You should join
Friends
with Highschooler
two times (for each ID
column)
select t1.ID1
, t2.grade
, t1.ID2
, t3.grade
from Friends t1
join Highschooler t2 on t1.ID1 = t2.ID
join Highschooler t3 on t1.ID2 = t3.ID
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.