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 |
|
boybles
Starting Member
23 Posts |
Posted - 2008-07-05 : 17:01:06
|
I have a mail table that references an employee table twice for each record. How can I pull off the following? Please Help!Boybles TABLES:Employee----------EmployeeID (smallint)EmployeeName (varchar)Mail----------MailID (smallint)MailName (varchar)MailFrom (smallint)MailTo (smallint)SAMPLE DATA:Employee-------1|Joe2|JaneMail-------1|Test Mail|1|2DESIRED RESULT:(MailFromName, MailToName would be aliases)MailName|MailFromName|MailToName---------------------------------Test Mail|Joe|Jane |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2008-07-05 : 21:29:38
|
[code]select m.MailName, MailFromName = f.EmployeeName, MailTonName = t.EmployeeNamefrom Mail m inner join Employee f on m.MailFrom = f.EmployeeID inner join Employee t on m.MailTo = t.EmployeeID [/code] KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
boybles
Starting Member
23 Posts |
Posted - 2008-07-06 : 21:16:01
|
Wonderful. Thanks for your help, Khtan!Boybles |
 |
|
|
|
|
|