SQL Server Self Joins

  • hi,

    This is my table..

    create table man

    (

    empid int primary key,

    empname varchar(50),

    managerid int references self(empid)

    )

    select * from man

    empid empname managerid

    ------- --------- --------

    1123sabeer 1124

    1124muqeem 1124

    1125seshu 1123

    1126ranga 1124

    1127sakee 1123

    use only self join query. i want ouput like this

    empid empname mangerid

    ------ --------- ----------

    1123 sabeer 1124(muqeem)

    1124muqeem 1124(muqeem)

    1125seshu 1123(sabeer)

    1126ranga 1124(muqeem)

    1127sakee 1123 (sabeer)

    i need self join query only?

    :P:P:P:P:P:P:P
    Thanks,
    Sabeer.M

  • hi i got the query.. 😛

    select e1.empname as manager,e2.empname from man e1,man e2

    where e1.empid=e2.managerid order by e1.managerid

    Thanks

    sabeer.M

    :P:P:P:P:P:P:P
    Thanks,
    Sabeer.M

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply