Skip to content
Advertisement

how to join one column to all columns from another table

I have two tables, players and lineup table with all players in the team

the lineup table have this columns

and all of the columns have the ID of the one player in the players table

How to join all the columns here to the player table ?

Advertisement

Answer

something in line with this:

basically a lot of left_joins.

If you redesing your database model and add table that will have columns: match_id, position_id, player_id things will be much simpler and database engine will be grateful to you.

then your SQL would look much simpler:

(something like that, did not check for accuracy here) there is additional table added holding a list of all positions in a match.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement