Help with query
От | ExpoShare.com |
---|---|
Тема | Help with query |
Дата | |
Msg-id | c507d6de04081116495af918be@mail.gmail.com обсуждение исходный текст |
Ответы |
Re: Help with query
|
Список | pgsql-novice |
I'm new to SQL and I am having a little difficulty trying to construct a query that will use the first table in the following list: TABLE coaching_relationships: coaching_relationship_id coach_id athlete_id TABLE athletes athlete_id user_id TABLE coaches coach_id user_id TABLE users user_id user_name And use sub-queries (or joins???) to return user names for the coaches and athletes like this: Coach | Athletes ================= Bill | Marge Bill | Anne Mary | Judith Simon | Esther Simon | Raymond Simon | Phyllis ...etc... I can't seem to make the leap from this: select c.user_id, a.user_id from athletes a, coaches c, coaching_relationships cr where a.athlete_id = cr.athlete_id and c.coach_id = cr.coach_id; which gives me: user_id | user_id ---------+--------- 1 | 1 8 | 1 9 | 2 3 | 4 3 | 5 3 | 6 8 | 10 8 | 11 9 | 7 To resolving it to names...can I use a sub-query to do this? Any chance somebody can show me how? Thanks, Ryan
В списке pgsql-novice по дате отправления: