sql select-如何根据外键从其他表中选择值

ev7lccsx  于 2021-06-20  发布在  Mysql
关注(0)|答案(1)|浏览(354)


我想要一个select语句,它包含server\u slseason中的sport、league和season列,但使用server\u sport.name、server\u season.year和server\u league.name作为值
我试过几句话,但都没用。
同样在服务器中,所有列都是引用主键的外键。

erhoui1w

erhoui1w1#

找到一个查询`

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;

`

相关问题