简体   繁体   中英

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. 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 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

INNER JOIN fr_nations as B ON A.id = B.confed_id

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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