SQL Select-如何根据一个人的外键从其他表中选择值

时间:2018-10-15 11:15:49

标签: mysql sql select inner-join

enter image description here

我希望有一条select语句,其中包含server_slseason中的运动,联赛和赛季列,但使用server_sport.name,server_season.year和server_league.name作为值

我尝试了一些陈述,但没有一个奏效。

也在server_slseason中,所有列都是引用其主键的外键。

1 个答案:

答案 0 :(得分:0)

找到一个查询`

select server_sport.name, server_season.year, server_league.name from server_slseason 
inner join server_sport on server_slseason.sport = server_sport.id 
inner join server_season on server_slseason.season = server_season.id
inner join server_league on server_slseason.league = server_league.id;

`