简体   繁体   中英

How to get data from another table matching 2 fields to same 1 field from another table

I have 3 table

Player Playerid Player name

Team Team id Player1 foreign key playerid from table(player) Player2 foreiy key playerid

Match Matchid Teamid Playerid

Now I want a player name from the player table for player1 and player2 in Dropdown box

I am doing it for a college project using php codeigniter and stuck at this Please help me on this anyone.

您的案例看起来像一个简单的JOIN查询

SELECT T.team_id, P1.player_name, P2.player_name from team T JOIN player P1 ON T.player1 = P1.player_id JOIN player P2 ON T.player2 = P2.player_id

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