Difference between JOIN and INNER JOIN

前端 未结 6 1857
离开以前
离开以前 2020-11-22 06:31

Both these joins will give me the same results:

SELECT * FROM table JOIN otherTable ON table.ID = otherTable.FK

vs

SELECT *         


        
6条回答
  •  甜味超标
    2020-11-22 07:13

    As the other answers already state there is no difference in your example.

    The relevant bit of grammar is documented here

     ::= 
        [ { INNER | { { LEFT | RIGHT | FULL } [ OUTER ] } } [  ] ]
        JOIN
    

    Showing that all are optional. The page further clarifies that

    INNER Specifies all matching pairs of rows are returned. Discards unmatched rows from both tables. When no join type is specified, this is the default.

    The grammar does also indicate that there is one time where the INNER is required though. When specifying a join hint.

    See the example below

    CREATE TABLE T1(X INT);
    CREATE TABLE T2(Y INT);
    
    SELECT *
    FROM   T1
           LOOP JOIN T2
             ON X = Y;
    
    SELECT *
    FROM   T1
           INNER LOOP JOIN T2
             ON X = Y;
    

提交回复
热议问题