• Steve Jones - Editor (5/27/2009)


    The corrected question, which is on the web site, is

    CREATE TABLE E (eid int, mid int, en char(10) )

    INSERT E SELECT 1,2,'Vyas'

    INSERT E SELECT 2,3,'Mohan'

    INSERT E SELECT 3,NULL,'Shobha'

    INSERT E SELECT 4,2,'Shridhar'

    INSERT E SELECT 5,2,'Sourabh'

    SELECT t1.en [Em], t2.en [Ma] FROM E t1, E t2 WHERE t1.mid = t2.eid

    order by t1.en

    There is no way you can get "Vyas Mohan" first.

    Running the SQL from the newsletter kind of defeats the purpose in answering. The idea is for you to use your knowledge to figure it out.

    Sure you can... read it from top down without the ORDER BY.

    eid 1 gives you Vyas which joins to eid 2 and gets Mohan

    Vyas Mohan

    followed by Mohan eid 2 joining to eid 3 and getting

    Mohan Shobha

    if you read the email, figured out what you were doing, and then clicked the link, and answered the question (because you didn't see the order by.. on my machine it was hidden by a scrollbar at first), you'd easily get Vyas Mohan first.



    --Mark Tassin
    MCITP - SQL Server DBA
    Proud member of the Anti-RBAR alliance.
    For help with Performance click this link[/url]
    For tips on how to post your problems[/url]