Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2011
    Posts
    1

    Unanswered: Two teams from one table

    It's a very basic simple problem but it's a nuscience to explain.

    I have a table called teams. (a list of team names -team.teamname)
    I have a table called fixtures - fixtures.team1 versus fixtures.team2 (both taken from a dropdown menu of the team table.

    When MS Access creates the SQL Select, it allows for just one "teamname"

    I'm using
    <% Response.Write (rsleague("teamname"))%>
    to write it just 1 team.

    How Can I change the syntax to something like
    <% Response.Write (rsleague("fixtures.team1"))%>
    <% Response.Write (rsleague("fixtures.team2"))%>

    so I can write both teams and not their numerical identifiers?

    If this needs to be moved to either the ASP or SQL forums please do do.

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    this might not have all the correct column names, but it should get you started...
    Code:
    SELECT fixtures.gamedate
         , fixtures.location
         , home.teamname AS hometeam
         , away.teamname AS awayteam
      FROM fixtures
    INNER 
      JOIN teams AS home
        ON home.id = fixtures.hometeam
    INNER 
      JOIN teams AS away
        ON away.id = fixtures.awayteam
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

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