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 2005 Forums
 Transact-SQL (2005)
 inner join outer join ??

Author  Topic 

Smiely
Starting Member

2 Posts

Posted - 2008-01-08 : 11:26:22
I have a basic query question. My query looks like....

select l.uid, l.value, u.lastname, u.firstname from labvalues l
inner join users u on u.id = l.uid
where l.labdate<='01/01/2007' and l.labdate>='01/01/2006' and l.testname='weight' and uid in
(32883,
33022,
32882,
71016,
33023)

This doesn't show the name of people who doesn't have weight listed. I would like to see the result with 5 rows for those 5 uids which may or may not have weight.

Please Help....

Smiely

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-01-08 : 11:29:20
[code]select l.uid,
l.value,
u.lastname,
u.firstname
from users as u
left join labvalues as l on l.uid = u.id
and l.labdate >= '01/01/2006'
and l.labdate < '01/01/2007'
and l.testname = 'weight'
WHERE u.uid in (32883, 33022, 32882, 71016, 33023)[/code]


E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

Smiely
Starting Member

2 Posts

Posted - 2008-01-08 : 11:59:59
THANKS Peso !! It worked !!!
Go to Top of Page
   

- Advertisement -