Solved

quaduplites records in datagridview from a 3 join sql query

Posted on 2014-10-20
8
44 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Suggested Solutions

Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Viewers will learn how the fundamental information of how to create a table.

732 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