[![已命名团队和比赛的桌子] [2]] [2]我有2张桌子
[2]:https://i.stack.imgur.com/7v4nT.png**strong个文本**
我需要从这2个表中获取数据,以便使用以下数据构成一个新表
在基于Tourid = 6的比赛表中的中,结果,日期,team1id,team2id,以及在团队表中我需要将Tname显示为team1,将Tname显示为team2。
答案 0 :(得分:0)
听起来像需要加入:
select matches.*,t1.Tname as team1,t2.Tname as team2 from matches
join team t1 on t1.Teamid=matches.team1id
join team t2 on t2.Teamid=matches.team2id
where tourid=6