简体   繁体   English

如何INNER JOIN超过两个类别?

[英]How to INNER JOIN more than two categories?

I'm a little confused in here and need some help... 我在这里有点困惑,需要一些帮助...

the situation is I've made three tables(fr_Leagues, fr_nations and fr_confeds), all i want to do is add a league which shows the name of the categories not the id with pagination. 情况是我已经制作了三个表(fr_Leagues,fr_nations和fr_confeds),我要做的就是添加一个联赛,该联赛显示类别的名称而不是带有分页的id。 Here is the code: 这是代码:

NOW FIXED! 现在修复!

  "SELECT 
 a.id as confed_id,
 a.fr_short_name as confed_name, 
     b.id as nation_id,
 b.fr_name as nation_name,
 c.id as league_id,
 c.fr_name as league_name"
." FROM fr_confeds as a 
INNER JOIN fr_nations as b ON a.id = b.confed_id 
INNER JOIN fr_leagues as c ON b.id = c.nation_id"
." LIMIT $paginate->start, $paginate->limit"

You are missing on how to link the different tables together. 您缺少如何将不同的表链接在一起的信息。 On each INNER JOIN, you need to have it: 在每个INNER JOIN上,您都需要拥有它:

INNER JOIN fr_nations ON a.<someColumn> = b.<anotherColumn> INNER JOIN fr_leagues ON a.<someColumn> = b.<anotherColumn>

USE THIS QUERY 使用此查询

SELECT * FROM fr_confeds as A SELECT * FROM fr_confeds为A

INNER JOIN fr_nations as B ON A.id = B.confed_id 内联接fr_nations为B ON A.id = B.confed_id

INNER JOIN fr_leagues as C ON B.confed_id = C.league_id INNER JOIN fr_leagues作为C ON B.confed_id = C.league_id

LIMIT $paginate->start, $paginate->limit LIMIT $ paginate->开始,$ paginate-> limit

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM