What joins does SQLite support?

前端 未结 1 979
执笔经年
执笔经年 2020-12-08 07:05

According to the join-op syntax, SQLite has 13 distinct join statements:

,
JOIN
LEFT JOIN
OUTER JOIN
LEFT OUTER JOIN
INNER JOIN
CROSS JOIN
NATURAL JOIN
NATUR         


        
相关标签:
1条回答
  • 2020-12-08 07:32

    The SQLite grammar is a bit different from the SQL-92 spec's, according to which, the following are illegal:

    *OUTER JOIN
    *NATURAL OUTER JOIN
    *NATURAL CROSS JOIN
    

    The first two, because a <join type>, in order to contain OUTER, must also include an <outer join type> before it. The last, because NATURAL can only occur in <qualified join>'s, not <cross join>'s. These don't appear to behave according to any spec, so it's a good idea to avoid them.

    As was answered on the mailing list, SQLite3 only supports three joins: CROSS JOIN, INNER JOIN, and LEFT OUTER JOIN. The following are equivalent:

    , == CROSS JOIN
    JOIN == INNER JOIN
    LEFT JOIN == LEFT OUTER JOIN
    

    As explained in the wikipedia article the NATURAL keyword is shorthand for finding and matching on same-name columns, and doesn't affect the the join type.

    According to the SQLite page, 'RIGHT' and 'FULLOUTER JOIN's are not supported.

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