Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 278
  • Last Modified:

duplicates

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
VBdotnet2005
Asked:
VBdotnet2005
  • 2
3 Solutions
 
Rajkumar GsSoftware EngineerCommented:
If there are more records in table2 or table3 for a record in table1, INNER JOIN will return all the records
0
 
Rajkumar GsSoftware EngineerCommented:
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
 
CboudrozCommented:
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

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now