Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2003
    Posts
    43

    Unanswered: Query for basketball game

    I've got a table containing basketball games and a table containing teams (se picture). I would like some help with a query that will select all the information from the games table and also get the names of the teams playing. The teams are as you can see referensed by "hometeam" and "awayteam" in "games". Is this even possible?
    Attached Thumbnails Attached Thumbnails tables.gif  
    Last edited by Oddish; 01-08-04 at 08:08.

  2. #2
    Join Date
    Mar 2003
    Posts
    43
    Wow, I'm better at this than I thougt! It suddenly just came to me! I would however appreciate some feedback on this SQL. Is is an ok query or can it be optimized in some way?
    Code:
    SELECT g.*, t1.name AS hometeam, t2.name AS awayteam
    FROM (games AS g INNER JOIN teams AS t1 ON g.hometeam = t1.teamid)
    INNER JOIN teams AS t2 ON g.awayteam = t2.teamid

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •