Results 1 to 2 of 2

Thread: Fetch and match two tables

  1. #1
    Join Date
    May 2006
    Posts
    266
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Fetch and match two tables

    Hi I have two tables that i need to be able to show the username when fetching data from table 2

    Table 1 is called - team
    the rows are:
    id
    teamname
    teamlogo

    in Table 2 - this table has the rounds so each team playing each other
    The rows:
    id - Match ID
    team1 - Team A (this gets the ID from the first table)
    team2 - Team B (this gets the ID from the first table)

    However when I want to show the names of the team that is versing each other because the team names are not in table 2 I cant show them.

    Can any one tell me how I get these two tables to communicate please.
    The web in one word.

  2. #2
    Join Date
    Mar 2009
    Posts
    65
    Thanks
    13
    Thanked 4 Times in 4 Posts

    Default

    I can't do it in one SQL statement (maybe a SQL expert could come along)

    First, retrive the team-ids

    select team1, team2 from table1, table2 where table1.id = table2.id

    Them get the names

    select teamname from table1 where id = $teamidID

    (note, $teamID is a variable)

    For some reasons, I don't think a combined SQL is possible. If it does, it is going to be one heck of a complicated one. I'll check around.

Bookmarks

Posting Permissions

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