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 2005 Forums
 Transact-SQL (2005)
 Duplicate data with join

Author  Topic 

JJ297
Aged Yak Warrior

940 Posts

Posted - 2007-11-15 : 14:58:50
Can someone tell me why I am getting duplicate data showing up? Here's my query:

SELECT

Titles.titleid, titles.title, titles.[descriptions], resources.quantityowned, classifications.[description]


FROM Titles
JOIN resources
ON Titles.titleid = resources.titleid
JOIN titleclassification
ON Titles.titleid = titleclassification.titleid
JOIN classifications
ON titleclassification.classificationid = classifications.classificationid
where titles.titleid='497'

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2007-11-15 : 15:01:19
Because that's what is in your tables.

Post some sample data for us to look at and what you want it to return.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

JJ297
Aged Yak Warrior

940 Posts

Posted - 2007-11-15 : 15:09:53
Here's the results of my query. See how the description is repeating. I should have one title per each description. Table is not listing it.

TitleID Title Descrip Qty Description
497 High Performance Teamwork NULL 7 Attitude
497 High Performance Teamwork NULL 7 Communication
497 High Performance Teamwork NULL 7 Coaching
497 High Performance Teamwork NULL 7 Facilitation
497 High Performance Teamwork NULL 7 Teams
497 High Performance Teamwork NULL 7 Attitude
497 High Performance Teamwork NULL 7 Communication
497 High Performance Teamwork NULL 7 Coaching
497 High Performance Teamwork NULL 7 Facilitation
497 High Performance Teamwork NULL 7 Teams
497 High Performance Teamwork NULL 7 Attitude
497 High Performance Teamwork NULL 7 Communication
497 High Performance Teamwork NULL 7 Coaching
497 High Performance Teamwork NULL 7 Facilitation
497 High Performance Teamwork NULL 7 Teams
497 High Performance Teamwork NULL 7 Attitude
497 High Performance Teamwork NULL 7 Communication
497 High Performance Teamwork NULL 7 Coaching
497 High Performance Teamwork NULL 7 Facilitation
497 High Performance Teamwork NULL 7 Teams
497 High Performance Teamwork NULL 7 Attitude
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2007-11-15 : 15:16:16
We'd have to see the data in your tables too that meet the join criteria.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

JJ297
Aged Yak Warrior

940 Posts

Posted - 2007-11-15 : 15:27:04
Never mind I got it. I was joining two other tables I didn't need. Thanks for you help.
Go to Top of Page
   

- Advertisement -