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 |
|
cimon
Starting Member
4 Posts |
Posted - 2009-06-22 : 13:50:25
|
| helloTable 1ID_One Supervisor_ID 21 4532 9112 67Table 2ID Name12 Jenny Jose32 Jack Hason67 Martin Lof21 Jeremy sal45 hina mat91 Cliena KiteI have to get the results as 21 Jeremy Sal 45 Hina Mat32 jack Hason 91 Cliena Kiteso onWhat's the best possible way to write the sql for this i am trying to use join, but not sure howselect T1.id_one , T1.supervisor_id, T2.NameFROM Table1 T1 LEFT OUTER JOINTable2 T2 ON T1.ID_One = T2.ID To the above query how can I add T2.name again so that I get the name corresponding to supervisor idthank youcimon |
|
|
rohitkumar
Constraint Violating Yak Guru
472 Posts |
Posted - 2009-06-22 : 14:03:42
|
| select T1.id_one , T1.supervisor_id, T2.Name, T3.NameFROM Table1 T1 LEFT OUTER JOIN Table2 T2ON T1.ID_One = T2.IDLEFT OUTER JOIN Table2 T3ON T1.Supervisor_ID = T3.ID |
 |
|
|
cimon
Starting Member
4 Posts |
Posted - 2009-06-22 : 14:15:34
|
quote: Originally posted by rohitkumar select T1.id_one , T1.supervisor_id, T2.Name, T3.NameFROM Table1 T1 LEFT OUTER JOIN Table2 T2ON T1.ID_One = T2.IDLEFT OUTER JOIN Table2 T3ON T1.Supervisor_ID = T3.ID
thank youtat works |
 |
|
|
|
|
|