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.
| Author |
Topic |
|
agpasam
Starting Member
2 Posts |
Posted - 2009-02-26 : 01:07:07
|
| I have two tablesTable1 Table2EID SID EID Name1 2 1 aaaaa2 1 2 sssssI want the result like thisEID NAME SID ALIASNAMESID1 aaaa 2 ssss2 ssss 1 aaaaCan anyonle help this |
|
|
Mangal Pardeshi
Posting Yak Master
110 Posts |
Posted - 2009-02-26 : 01:29:10
|
| [code]SELECT A.eid, B.name, A.SID, c.NameFROM Table1 A INNER JOIN Table2 BON A.eid = B.eidINNER JOIN Table2 CON A.sid = C.Eid[/code]Mangal Pardeshihttp://mangalpardeshi.blogspot.com |
 |
|
|
bklr
Master Smack Fu Yak Hacker
1693 Posts |
Posted - 2009-02-26 : 01:44:11
|
| try this toodeclare @Table1 table(eid int , sid int)insert into @table1select 1,2 union all select 2,1declare @Table2 table(eid int , name varchar(32))insert into @table2select 1,'aaaaa' union all select 2,'sssss'select eid , (select name from @table2 where eid = t.eid ) as name,sid, (select name from @table2 where eid = t.sid ) as namefrom @table1 t |
 |
|
|
agpasam
Starting Member
2 Posts |
Posted - 2009-02-26 : 02:04:54
|
| HiThanks ALL for your valuable answerI got it. |
 |
|
|
bklr
Master Smack Fu Yak Hacker
1693 Posts |
Posted - 2009-02-26 : 02:21:58
|
| welcome |
 |
|
|
|
|
|