有如下两张表,如图所示

matches的hid(主队ID)与gid(客队ID)与team表的tid关联
怎么样写SQL语句产生以下的效果?
1.广州恒大 3:0 北京国安
2.上海上港 2:1 江苏苏宁
……
求指点。谢谢。

matches的hid(主队ID)与gid(客队ID)与team表的tid关联
怎么样写SQL语句产生以下的效果?
1.广州恒大 3:0 北京国安
2.上海上港 2:1 江苏苏宁
……
求指点。谢谢。
解决方案
20

select b.tname, a.score,c.tname from matches as a join team as b on b.id=a.hid join team as c on c.id=a.gid
30
select id, (select tname from team where tid=hid) as HostTeam, score, (select tname from team where tid=gid) as GuestTeam from matches