Forum Moderators: coopster

Message Too Old, No Replies

multiple joins?

         

skoff

5:05 pm on Sep 21, 2011 (gmt 0)

10+ Year Member



i have 2 tables, calendar and teams.
in my calendar table i have 2 columns, home and away. In these column there is the id of the team. What i want to do is to show the name for each team instead of the ID.

Demaestro

6:21 pm on Sep 21, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



hey skoff

I think this is what you are wanting to do.

SELECT
t.team_name
FROM
teams t left join calendar c on c.home = t.team_id

If you have questions post back

skoff

7:12 pm on Sep 21, 2011 (gmt 0)

10+ Year Member



i want for both team home and away this is where i have a problem.. :S

httpwebwitch

7:31 pm on Sep 21, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



SELECT
calendar.home,
(SELECT teams.name FROM teams WHERE teams.id = calendar.home) as homename,
calendar.away,
(SELECT teams.name FROM teams WHERE teams.id = calendar.away) as awayname
FROM calendar

skoff

7:42 pm on Sep 21, 2011 (gmt 0)

10+ Year Member



great! Big thanks to you httpwebwitch that's exactly what i was looking for!