• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 496
  • Last Modified:

Self-Join

Need help with the following:

Display the employee's last name and employee number along with the manager's last name and manager_number.

This is what I have but it returns: no statement parsed

Select worker.last_name, worker.emloyee_id, manager.last_name, manager.manager_id
From employees worker, employees manager
Where worker.manager_id = manager.employee_id

Any suggestions would be helpful
0
dc0819
Asked:
dc0819
  • 2
1 Solution
 
mawniCommented:
Select
worker.last_name,
worker.emloyee_id,
manager.last_name,
manager.manager_id
From employees worker,
employees manager
Where
worker.manager_id = manager.employee_id;

yes what you did solves your problem, but I think you must use distinct or group by employee ID, because I am sure that there are many employees that shares the same manager!
0
 
jaiminpsoniCommented:
Select worker.last_name, worker.employee_id, manager.last_name, manager.employee_id
From employees worker, employees manager
Where worker.manager_id = manager.employee_id
0
 
jaiminpsoniCommented:
From your query....
Select worker.last_name, worker.emloyee_id, manager.last_name, manager.manager_id

you dont need id of manager's manager, right? if you need id of employee, get manager.employee_id

@mawni,
"you must use distinct or group by employee ID"
Why would we need to do group by? We are not usign any group function here. Are we?
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now