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
 General SQL Server Forums
 New to SQL Server Programming
 dup rows with join

Author  Topic 

dainova
Starting Member

31 Posts

Posted - 2010-08-09 : 13:30:28
Hi, guys

Can you help me understand why I'm getting dup rows for the following select with joins?

select d.id_acct, b.id_access, c.id_right, from nels.ls_pooluser d
join nels.ls_accessright b on b.id_access = d.id_access
join nels.ls_right c on c.id_right = b.id_right
order by 1,3,4 ;


And it's dup for only one of 3 available d.id_acct values, the one = 20.

ID_acct ID_access ID_RIGHT
---------------------- ---------------------- ----------------------
10 1 1
10 1 2
10 1 3
10 1 4
10 1 5
10 1 6
10 1 7
10 1 8
10 1 9
10 1 10
10 1 11
20 2 2 <== dups
20 2 2
20 2 3
20 2 3
20 2 4
20 2 4
20 2 5
20 2 5
20 2 6
20 2 6
30 3 3
30 3 4
30 3 5


Tx
T

slimt_slimt
Aged Yak Warrior

746 Posts

Posted - 2010-08-09 : 13:57:12
which SQL server are you using? 2000 or 2005+ ?
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-08-10 : 13:25:10
that means you either have duplicates on table nels.ls_accessright or nels.ls_right for same value of id_access or id_right

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -