Click here to Skip to main content
15,672,517 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi I have the following table struture:
test[emp_name,emp_id,dept,mgr_id,sal].
Now I want to display all the employees emp name,dept along with their manager name.
I have written the following query:
select emp_name,emp_id,mgr_id from test t1,
emp_name as manager_name from test t2 where
t1.mgr_id=t2.emp_id

but it's giving the following error:
Msg 156, Level 15, State 1, Line 2
Incorrect syntax near the keyword 'from'.
Posted
Updated 3-May-10 21:02pm
v2

1 solution

Try

SQL
select t1.emp_name,t1.emp_id,t1,mgr_id,
t2.emp_name as manager_name from testt1, test t2 where
t1.mgr_id=t2.emp_id
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900