SQL gurus: lookup syntax

Discussion in 'OT Technology' started by teo, Nov 9, 2005.

  1. teo

    teo . => ? => !

    Joined:
    Aug 26, 2004
    Messages:
    3,094
    Likes Received:
    0
    Location:
    Eh?
    I have three tables:
    players [id, firstname, lastname]
    teams [id, teamcity, teamname]
    pools2 [a lot of fields, lol]

    The primary keys are foreign keys in the 'pool' table, and I'm doing an inner join. I'm trying to create a lookup so that I can reference the names instead of the IDs in my recordset, but I'm not sure where to start. Here's the SQL I currently have:

    "SELECT * FROM (POOLS2 INNER JOIN PLAYERS ON POOLS2.PLAYERID=PLAYERS.PLAYERID) INNER JOIN TEAMS ON POOLS2.TEAMID=TEAMS.TEAMID"

    Any input would be appreciated. If there's a better way to write the SQL statement, great! (I suck at SQL, lol...)
     
  2. SLED

    SLED build an idiot proof device and someone else will

    Joined:
    Sep 20, 2001
    Messages:
    28,118
    Likes Received:
    0
    Location:
    AZ, like a bauce!
    Code:
    SELECT players.firstname, players.lastname, teams.teamcity, 
        teams.teamname, ( and whatever other fields you want displayed here )
    FROM POOLS2 
       INNER JOIN PLAYERS ON POOLS2.PLAYERID=PLAYERS.PLAYERID
       INNER JOIN TEAMS ON POOLS2.TEAMID=TEAMS.TEAMID
    
    
     
  3. teo

    teo . => ? => !

    Joined:
    Aug 26, 2004
    Messages:
    3,094
    Likes Received:
    0
    Location:
    Eh?
    :doh: thanks! ;)
     

Share This Page