June 26, 2013 at 6:03 am
Hai friends,
create table users
(
user_id varchar(10),
username varchar(10),
designation varchar(10),
department varchar(10),
reporting_to varchar(10)
)
insert into users(user_id,username,designation,department,reporting_to)
values('0010','A','salesman','Marketing','00005')
insert into users(user_id,username,designation,department,reporting_to)
values('0005','AA','Manager','Marketing','00001')
insert into users(user_id,username,designation,department,reporting_to)
values('0001','ABC','MD','Marketing','0001 ')
my requirement is how to display all reporting_to peoples with their name.?
example:
if i choose reporting_to of "A" Users ll show like below
A is reporting_to==>'0005 : AA' like
June 26, 2013 at 6:12 am
create table users
(
user_id varchar(10),
username varchar(10),
designation varchar(10),
department varchar(10),
reporting_to varchar(10)
)
insert into users(user_id,username,designation,department,reporting_to)
values('0010','A','salesman','Marketing','0005')
insert into users(user_id,username,designation,department,reporting_to)
values('0005','AA','Manager','Marketing','0001')
insert into users(user_id,username,designation,department,reporting_to)
values('0001','ABC','MD','Marketing','0001 ')
select a.*,b.username from users a
join users b
on a.reporting_to=b.user_id
Pramod
SQL Server DBA | MCSE SQL Server 2012/2014
in.linkedin.com/in/pramodsingla/
http://pramodsingla.wordpress.com/
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply