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 2000 Forums
 SQL Server Development (2000)
 left outer join and results

Author  Topic 

pelegk2
Aged Yak Warrior

723 Posts

Posted - 2006-03-07 : 09:14:46
i have few tales
and i am making a select lik this

select *,usersentrance.date1 from users left join usersdata on......
left outer join usersentrance on users.id=usersdata.id
......(and it continues with some more left outer join's)

the thing is that in the usersentrance i have at least 20 rows for an id that i check,and in the selec above i recive 1 rows wih a data
in which the usersentrance.date1 has a date (not the last entrance date but atnoher 1 form few months back!!!)
how comes?
how the sql server decided which id to take?
thnaksi nadvance
peleg

Israel -the best place to live in aftr heaven 9but no one wan't to go there so fast -:)

pelegk2
Aged Yak Warrior

723 Posts

Posted - 2006-03-08 : 02:58:36
i will start again
i have 3 tables:
users with userid,username,pass
usersdata with userid,name,last name,phone,cellolar an so on.....
usersentrance with userid,ip,dattime,browser type

my select is like this
[CODE]
select * from users
inner join usersdata on
users.userid=usersdata.userid
[/CODE]
this will bring me 1 row with all the data of 2 tables
then i add

[CODE]
select * from users
inner join usersdata on
users.userid=usersdata.userid
left outer join usersentrance on
users.userid=usersentrance.userid
[/CODE]

now 2 questins :
1)why do i recive only 1 line, where in the usersentrance table i have say 20 lines for a given userid? (i thought i should recive 20 lies in which most of the data is the same except fir the data from the usersentrance table)?
2)why or how th e sql server decide which from the 20 rows to bring?
why not the first or last?
thnaks in advance
peleg


Israel -the best place to live in aftr heaven 9but no one wan't to go there so fast -:)
Go to Top of Page
   

- Advertisement -