Saturday, 14 September 2013

How do I use one row to pull multiple other rows from the same mySQL table

How do I use one row to pull multiple other rows from the same mySQL table

So, lets say i have a user table. Each user has the ability to be in a
team with upto 3 other users. So for now i have a column for each spot in
the team(4 columns total, so your own id fills in a spot so you know where
you fit in the team). And i put the ids to the other members of the team
in each of the other columns. In the end, everyone on one team would have
the same values in those 4 columns.
How would i query sql to look at those ids and pull the info for all the
other users on there team (so by looking at one user, i can pull all 4
team members rows)? Is this the most efficient way of storing that data?

No comments:

Post a Comment