Solved

Self-Join

Posted on 2011-02-24
3
493 Views
Last Modified: 2012-06-22
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
Comment
Question by:dc0819
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 4

Expert Comment

by:mawni
ID: 34972537
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
 
LVL 5

Accepted Solution

by:
jaiminpsoni earned 500 total points
ID: 34973491
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
 
LVL 5

Expert Comment

by:jaiminpsoni
ID: 34973538
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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As they say in love and is true in SQL: you can sum some Data some of the time, but you can't always aggregate all Data all the time! Introduction: By the end of this Article it is my intention to bring the meaning and value of the above quote to…
If you find yourself in this situation “I have used SELECT DISTINCT but I’m getting duplicates” then I'm sorry to say you are using the wrong SQL technique as it only does one thing which is: produces whole rows that are unique. If the results you a…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

724 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question