Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2012

    Smile Unanswered: Multiple joins to the same column

    Hi guys,
    I'm putting together the site for a local darts league, essentially each of the teams completes an 'e-scorecard' for that particular game. This is then stored in a table named 'scorecardIndex' :

    scxUID(PK) scxTeam1(int) scxTeam2(int) scxTeam1Capt(int) scxTeam2Capt(int) scxDate(nvarchar 50) scxSubmitBy(int)

    So each 'index' points off to the UID of the player who was captain, and the UID of of each team.

    What I'm struggling with is joining this all together, as I'm joining both scxTeam1Capt and scxTeam2Capt to the same columns in the 'players' table (plFirstName, plSurname)

    plUID(PK) plFirstName(nvarchar 50) plSurname(nvarchar 50) plTeamUID(int) plEmail(nvarchar80) plPassword(nvarcharMAX)

    And equally joining scxTeam1 & scxTeam2 to the Teams table to pull back the teams actual name.

    Using several inner joins I can pull back the entire row for each team, but the columns have the same name..

    SELECT *
    FROM scorecardIndex AS S
    INNER JOIN teams AS T1
    ON T1.teamUID = S.scxTeam1
    INNER JOIN teams AS T2
    ON T2.teamUID = S.scxTeam2

    I'm using MS SQL Server 2008 R2.

    I've tried to be as detailed as possible without overdoing it, please let me know if I should have provided any additional information.

    Many thanks

  2. #2
    Join Date
    Jan 2003
    Provided Answers: 17
    You will probably hear a lot of "Don't use 'select *' for queries". This is one of the reasons. ;-)

    You just need to qualify the columns. For example:
    select getdate() as "Today", getdate() as "RightNow"

  3. #3
    Join Date
    Feb 2004
    In front of the computer
    Provided Answers: 54
    Yes, they do have the same names.

    Do you have a question?

    FYI, I'm paranoid about security but even I chuckled at the plPassword data type!

    In theory, theory and practice are identical. In practice, theory and practice are unrelated.

  4. #4
    Join Date
    Apr 2012
    Hey Pat,
    What data type should I be using for the password field?


Tags for this Thread

Posting Permissions

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