Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 JOIN Query Syntax

Author  Topic 

Bobba Buoy
Starting Member

36 Posts

Posted - 2005-01-13 : 07:49:28
I have a query that I am running out of sql server 2000 that is pulling duplicate records. I can probably figure it out but I am wondering if someone could look at it and point out errors in my syntax and/or structure.

Thanks!


code:--------------------------------------------------------------------------------
SELECT p.ParticipantID, pr.RaceID, p.FirstName, p.LastName, pr.Bib, p.Gender, pr.Age,
pr.AgeGrp, p.DOB, p.Address, p.City, p.St, p.Zip, pr.Clyde, pr.WhlChr, pr.RcWlk,
p.Phone, p.Email, reg.ShrtSize, reg.ShrtStyle, reg.WhereReg, reg.DateReg, reg.AmtPd
FROM Participant p INNER JOIN PartReg reg ON p.ParticipantID = reg.ParticipantID JOIN PartRace pr
ON pr.ParticipantID = p.ParticipantID JOIN RaceData rd ON pr.RaceID = rd.RaceID
WHERE (rd.EventID = 45 AND pr.RaceID = reg.RaceID) ORDER BY p.LastName
--------------------------------------------------------------------------------

nr
SQLTeam MVY

12543 Posts

Posted - 2005-01-13 : 08:34:19
Are you joining on unique criteria?

Pick out a duplicate - filter for it in the where clause then change the select statement to select *.
You will find the rows different - just find the table the differences come from - that will be where the jion problem is.

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2005-01-13 : 09:39:42
make sure you understand that if you join two tables, the "header" table will have it's values repeated over and over for each row in the "detail" table. i.e., when you join a table of Customers and a table of ORders, the customer info will be repeated over and over for each row in the Orders table.

If this doesn't make sense, stop what you're doing and ask specific questions because it's a key concept.

- Jeff
Go to Top of Page
   

- Advertisement -