I have a database with a EMPLOYEES table that has the following columns:
(EmpID char(4) unique Not null,
Ename varchar(10),
Job varchar(9),
MGR char(4),
Hiredate date,
Salary decimal(7,2),
Comm decimal(7,2),
DeptNo char(2) not null,
Primary key(EmpID),
Foreign key(DeptNo) REFERENCES DEPARTMENTS(DeptNo));
With a sample INSERT:
insert into EMPLOYEES values (7654,'Martin','Salesman',7698,'28-Feb-12',1250,1400,30);
I cannot figure out how to list all employees and their managers by manager name. I do not know how to display a manager name, just the number.
The query from your comment is wrong, as it performs the
JOINon the Ename.Try this:
Your original query joined the table on the name. You should tie the MGR id to the EmpID to find the manager.