Help with sql script [message #21783] |
Thu, 29 August 2002 12:06 |
Arpit
Messages: 99 Registered: March 2001
|
Member |
|
|
Hello,
Can someone help me out with this.
I have two tables, CLIENT AND EMPLOYEE
ClIENT EMPLOYEE
-------- -----------
CREATED_BY EMPLOYEE_NO
MODIFIED_BY EMPLOYEE_NAME
where if created_by = 100 then employee_no=100 and employee_name is "Mr. XYZ" meaning client.created_by=employee.employee_no
How can I in my *select* statement retreive both the created_by field and modified_by fields not with the numbers but with the names (employee_name)
Your help on this would be highly appreciated.
|
|
|
Re: Help with sql script [message #21784 is a reply to message #21783] |
Thu, 29 August 2002 12:30 |
Todd Barry
Messages: 4819 Registered: August 2001
|
Senior Member |
|
|
select c.*, e1.employee_name created_by_name, e2.employee_name modified_by_name
from client c, employee e1, employee e2
where e1.employee_no = c.created_by
and e2.employee_no (+)= c.modified_by;
I specified the join on modified_by as an outer join (+) in case this column is NULL until modified. If it initially has the same value as created_by, then the outer join is not required.
|
|
|