Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 152
  • Last Modified:

3 JOIN QUERY AGAIN

HEY i HAVE AN IDENTICAL SQL STATEMENT WORKING GOT ERROR MESSAGE ERROR NEAR where

Sql = " SELECT Injuries.Name, Injuries.Pos, Team.Fullname,Injuries.Date,Injuries.Injury,Injuries.Status,Injuries.Fantasy,Injuries.Type,"
        Sql += " Injuries.TeamID, Injuries.PlayerID"
        Sql += " FROM Injuries Join NFLPlayers np Join Injuries ON np.PlayerID = Injuries.PlayerID Join Teams ON Teams.TeamID = Injuries.TeamID WHERE"
        Sql += " SportCode ='AB' Order By Injuries.Date DESC"

Open in new window

Any ideas? I had it working then I throw in teams to join on teamid
0
powerztom
Asked:
powerztom
2 Solutions
 
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
Dude, lose the ALL CAPS.

>  Sql += " FROM Injuries Join NFLPlayers np Join Injuries ..
For starters, there are two tables named Injuries, so T-SQL won't be able to tell from which one the columns are coming from.   Alias both of these.
0
 
Aneesh RetnakaranDatabase AdministratorCommented:
Time to write stored procedures
0
 
Jason SchlueterIT ManagerCommented:
Try this.  You have an extra Injuries join.

SELECT Injuries.Name,
       Injuries.Pos,
       Team.Fullname,
       Injuries.Date,
       Injuries.Injury,
       Injuries.Status,
       Injuries.Fantasy,
       Injuries.Type,
       Injuries.TeamID,
       Injuries.PlayerID
FROM   Injuries
       JOIN NFLPlayers np
         ON np.PlayerID = Injuries.PlayerID
       JOIN Teams
         ON Teams.TeamID = Injuries.TeamID
WHERE  SportCode = 'AB'
ORDER  BY Injuries.Date DESC 

Open in new window

0
 
powerztomAuthor Commented:
Thanks for writing that one out You sayed me alot of time.Thanks
0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now