Solved

duplicates

Posted on 2011-02-11
3
249 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
  • 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

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

Suggested Solutions

Title # Comments Views Activity
Need Counts 11 43
sql query to reportserver  table error 3 24
Update in Sql 7 8
SQL Query for Periods 3 0
In this article—a derivative of my DaytaBase.org blog post (http://daytabase.org/2011/06/18/what-week-is-it/)—I will explore a few different perspectives on which week today's date falls within using Microsoft SQL Server. First, to frame this stu…
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…
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Viewers will learn how the fundamental information of how to create a table.

760 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

19 Experts available now in Live!

Get 1:1 Help Now