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.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Compare two Columns Query Help

Author  Topic 

pmaple66
Starting Member

2 Posts

Posted - 2005-04-19 : 17:49:33
Hey All, I'm having problems with this Query. I have a DB that I'm writing a query through MS SQL enterprise Manager. Majorly simplfied here it is:

Table contains three columns, employeeid employeeLastName, supervisorid

Every employee has a supervisor assigned to them. That supervisor id is also located in the employeeid column, just in a different area, example:

employeeid: employeeLastName supervisorid
125263 Smith 125266
125266 Jones 124423

The end user wants to know the supervisor's last name not the id. Ive bunch of different things, but I am a newbie to sql. Basically I want to do something that says if supervisorid IN employeeid display supervisorid. Ive tried unions, a sub select statement, but I'm always off somewhat. I have access to do anything I want on the DB. Can someone point me in the right direction?

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2005-04-19 : 17:54:15
SELECT e1.EmployeeID, e1.EmployeeLastName, e2.EmployeeLastName
FROM Employee e1
INNER JOIN Employee e2
ON e1.SupervisorID = e2.EmployeeID

Tara
Go to Top of Page

pmaple66
Starting Member

2 Posts

Posted - 2005-04-20 : 12:06:57
That was it! Thank you!!!!!!!!!!!!!!!!
Go to Top of Page
   

- Advertisement -