Solved

quaduplites records in datagridview from a 3 join sql query

Posted on 2014-10-20
8
24 Views
Last Modified: 2016-08-02
Hey I wrote a query where I join 3 tables I'm getting same player 4 times I have no Idea why. here is sql queies
 sql = "SELECT np.FirstName, np.LastName, np.Position,Teams.Fullname, np.College,np.Status,np.Jersey, np.Height,"
        sql += " np.Weight, np.Born, np.BioHtml, np.HighSchool,np.TeamID, np.PlayerID, np.NCAAID, Draft.draftyear, Draft.round,Draft.DraftPos, Draft.OverallPos, Draft.DraftTeamID, Draft.OrigTeamID"
        sql += " FROM NFLPlayers np Join Teams ON Teams.TeamID = np.TeamID Join Draft ON Draft.PlayerID = np.NCAAID WHERE"
        sql += " Status ='A' AND Position<> ''"
       

        connection = New SqlConnection(connetionString)

        Try
            connection.Open()
            adapter = New SqlDataAdapter(sql, connection)
            adapter.Fill(ds)
            connection.Close()
            DataGridView1.DataSource = ds.Tables(0)

Open in new window


here is what is outputted
APP LOOK
What am I doing wrong? EE Please help
0
Comment
Question by:powerztom
  • 2
  • 2
8 Comments
 
LVL 65

Accepted Solution

by:
Jim Horn earned 500 total points
ID: 40392549
Eyeballeth the JOIN ... ON columns between the two tables, as 'quadruples' indicates there may be more than one place where either (1) there is a one-to-many table and you're not uniquely defining the 'many' row to grab, so it returns many, or (2)  there is another ON column that's missing and you need to identify
0
 

Author Comment

by:powerztom
ID: 40397341
I've requested that this question be deleted for the following reason:

I figured out that I didn't need to use 3 join query.
0
 
LVL 65

Expert Comment

by:Jim Horn
ID: 40397342
Please spell out in greater detail how this was 'figured out', so we can accept that answer so others may benefit.
Cancelling delete request.
0
 

Assisted Solution

by:powerztom
powerztom earned 0 total points
ID: 40397400
Well I made the mistake of thinking the NFLPlayers table had a field called NCAAID and I thought that that field could join a field in the Draft table called PlayerID. WELL they don't match cause PlayerID is NFL AND NCAAID was college. But in NFLPLAYERS Table has a field called PlayerID That matches raft Table's PlayerID FIELD. aND THAT IS THE Connection that matches. I should have saw this from the beginning.Lesson don't assume and rush without taking a good look at your situation.
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Let's review the features of new SQL Server 2012 (Denali CTP3). It listed as below: PERCENT_RANK(): PERCENT_RANK() function will returns the percentage value of rank of the values among its group. PERCENT_RANK() function value always in be…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

762 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now