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 |
|
tpiazza55
Posting Yak Master
162 Posts |
Posted - 2007-01-05 : 15:32:16
|
| i have a query with some inner joins that return information about an employee i am running into a problem in that i need one employees email based on one inner join and anothers based on another inner join -- is there a way to get both in one query?select employee.email , bunch of other stufffrom workINNER JOIN technician ON business_location.technician_id = technician.technician_id inner join salesrep on business_location.salesrepid = salesrep.salesrep_idnot sure how to get both of those to employee.emp_id and get the emailtechnician.technician_id = employee.emp_idsalesrep.salesrep_id = employee.emp_id |
|
|
snSQL
Master Smack Fu Yak Hacker
1837 Posts |
Posted - 2007-01-05 : 15:47:21
|
| You haven't really given enough to go on, in the query you gave you have a table named work that you never use and another named business_location that you use in the joins without having introduced the table in the query first - so I'm guessing, but you can do what you want - just join the same table twice with aliases something like thisselect E1.email , E2.email , bunch of other stufffrom workINNER JOIN technician ON business_location.technician_id = technician.technician_id inner join salesrep on business_location.salesrepid = salesrep.salesrep_idinner join employee E1 on technician.technician_id = E1.emp_idinner join employee E2 on salesrep.salesrep_id = E2.emp_id |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
|
|
|
|
|