Solved

3 JOIN QUERY AGAIN

Posted on 2014-11-04
4
141 Views
Last Modified: 2014-11-04
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
Comment
Question by:powerztom
4 Comments
 
LVL 65

Assisted Solution

by:Jim Horn
Jim Horn earned 100 total points
ID: 40422544
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
 
LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 40422590
Time to write stored procedures
0
 
LVL 5

Accepted Solution

by:
Jason Schlueter earned 400 total points
ID: 40422618
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
 

Author Closing Comment

by:powerztom
ID: 40422646
Thanks for writing that one out You sayed me alot of time.Thanks
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question