• You did not get any results because you probably did not have records in table "Tickets" where "Reported_by = Assign_to"

    SELECTUsersTbl.Name AS first, UsersTbl.Name AS second

    FROMTickets

    INNER JOINUsersTbl ON Tickets.Reported_by = UsersTbl.Id -- Fine, upto this point

    INNER JOINUsersTbl AS UsersTbl_1 ON Tickets.Assign_to = UsersTbl.Id -- Here, you are accessing the table with alias name "UsersTbl_1"

    /*Hence, the above query is equivalent to the below query*/

    SELECTUsersTbl.Name AS first, UsersTbl.Name AS second

    FROMTickets

    INNER JOINUsersTbl ON Tickets.Reported_by = UsersTbl.Id AND Tickets.Assign_to = UsersTbl.Id -- You can move the condition up like this

    INNER JOINUsersTbl AS UsersTbl_1 ON 1 = 1

    /*The above query is again equivalent to below query*/

    SELECTUsersTbl.Name AS first, UsersTbl.Name AS second

    FROMTickets

    INNER JOINUsersTbl ON Tickets.Reported_by = UsersTbl.Id AND Tickets.Assign_to = UsersTbl.Id

    CROSS JOINUsersTbl AS UsersTbl_1


    Kingston Dhasian

    How to post data/code on a forum to get the best help - Jeff Moden
    http://www.sqlservercentral.com/articles/Best+Practices/61537/