Solved

duplicates

Posted on 2011-02-11
3
267 Views
Last Modified: 2012-05-11
I have three sample tables. All there has id field.
Why does it return duplicates accounts?


select a.field1, b.field1, c.field2
from table1 a
inner join table2 b
on a.id = b.id
inner join table3 c
on a.id = c.id
0
Comment
Question by:VBdotnet2005
[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
3 Comments
 
LVL 23

Assisted Solution

by:Rajkumar Gs
Rajkumar Gs earned 83 total points
ID: 34873770
If there are more records in table2 or table3 for a record in table1, INNER JOIN will return all the records
0
 
LVL 23

Accepted Solution

by:
Rajkumar Gs earned 83 total points
ID: 34873796
For eg:-
If table1 have 1 record.
table2 have related 5 records
then INNER JOIN will return 5 records

Hope you are clear
Raj
0
 
LVL 7

Assisted Solution

by:Cboudroz
Cboudroz earned 42 total points
ID: 34874064
because the id field is probably unique in each database or you don't have correct ON clause.

example:

 
select 
	*
from 
	employes e
	inner join function f
		on e.employe_id = f.employe_id 
where 
	e.employe_id = 1

Open in new window



you will have two row for same employe if the employe got two different function in the compagnie.

0

Featured Post

Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

Question has a verified solution.

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

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
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 to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

615 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