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 problem.

Author  Topic 

kamal.A
Yak Posting Veteran

70 Posts

Posted - 2009-07-22 : 06:25:25
Hi All,

Eg..I have two tables.

table1

UserId Name age

1 kamal 29
2 venkat 24
3 baskar 24

table2

attendanceId date UserId ApprovedBy

1 7/21/2009 2 1
2 7/21/2009 3 1

i want to display the following format.


Name date ApprovedBy

Venkat 7/21/2009 kamal
baskar 7/21/2009 kamal

I have used inner join and fetch the name from table1. how can i get the ApprovedBy? kinldy help me,

thanks in advance...
Regards,
Kamal.

bklr
Master Smack Fu Yak Hacker

1693 Posts

Posted - 2009-07-22 : 06:29:37
select t.name ,a.date,t1.name
from table1 t
inner join table2 a on a.userid = t.userid
inner join table1 t1 on t1.userid = a.approvedby
Go to Top of Page

kamal.A
Yak Posting Veteran

70 Posts

Posted - 2009-07-22 : 06:38:35
Its working fine. Thanks. kamal....
Go to Top of Page

bklr
Master Smack Fu Yak Hacker

1693 Posts

Posted - 2009-07-22 : 06:49:01
welcome
Go to Top of Page
   

- Advertisement -