Join multiple columns from one table to single column from another table

后端 未结 4 1922
Happy的楠姐
Happy的楠姐 2020-12-13 10:55

I\'m trying to learn how to join multiple columns from one table to a single column from another table.

This is my table structure in its simplest form:

4条回答
  •  -上瘾入骨i
    2020-12-13 11:25

    You need to join twice:

    SELECT t1.team_name as team1, t2.team_name as team2, trades.team_t, trades.team_2 
    FROM teams t1, teams t2, trades 
    WHERE t1.id = trades.team_1 and t2.id = trades.team_2
    

提交回复
热议问题