Page 125 - SQL
P. 125

clause. In this case it's the Employees table twice, so the intermediate table will look like this (I've
        removed any fields not used in this example):



          e.Id  e.FName       e.ManagerId      m.Id   m.FName       m.ManagerId

          1     James         NULL             1      James         NULL


          1     James         NULL             2      John          1


          1     James         NULL             3      Michael       1

          1     James         NULL             4      Johnathon     2


          2     John          1                1      James         NULL

          2     John          1                2      John          1


          2     John          1                3      Michael       1


          2     John          1                4      Johnathon     2

          3     Michael       1                1      James         NULL


          3     Michael       1                2      John          1

          3     Michael       1                3      Michael       1


          3     Michael       1                4      Johnathon     2

          4     Johnathon     2                1      James         NULL


          4     Johnathon     2                2      John          1


          4     Johnathon     2                3      Michael       1

          4     Johnathon     2                4      Johnathon     2


        The next action is to only keep the records that meet the JOIN criteria, so any records where the
        aliased e table ManagerId equals the aliased m table Id:



          e.Id  e.FName       e.ManagerId      m.Id   m.FName      m.ManagerId

          2     John          1                1      James        NULL


          3     Michael       1                1      James        NULL


          4     Johnathon     2                2      John         1


        Then, each expression used within the SELECT clause is evaluated to return this table:




        https://riptutorial.com/                                                                             107
   120   121   122   123   124   125   126   127   128   129   130