Join operators and commutativity

后端 未结 1 1735
长发绾君心
长发绾君心 2021-01-27 22:29

I am doing some relational algebra exercizes. On a teacher slide I saw a thing that makes me think that there can be an error. I think, the third JOIN, should be



        
1条回答
  •  时光说笑
    2021-01-27 22:55

    The order of the columns in the ON part of the statement doesn't influence how the JOIN itself is done.

    This:

    SELECT t1.columnA, t2.columnB
    FROM Table1 t1
       JOIN Table2 t2 ON t1.ID = t2.ID
    

    will yield the same results as this:

    SELECT t1.columnA, t2.columnB
    FROM Table1 t1
       JOIN Table2 t2 ON t2.ID = t1.ID
    

    The self-join you described would have been something like this:

    SELECT t1.columnA, t2.columnB
    FROM Table1 t1
       JOIN Table1 t2 ON t1.managerID = t2.employeeID
    

    0 讨论(0)
提交回复
热议问题