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 NATURAL LEFT JOIN NATURAL OUTER JOIN NATURAL LEFT OUTER JOIN NATURAL INNER JOIN NATURAL CROSS JOIN
Are they all unique? Which are equivalent?
SQLite JOINS are used to retrieve data from multiple tables. A SQLite JOIN is performed whenever two or more tables are joined in a SQL statement. There are different types of SQLite joins: INNER JOIN (or sometimes called simple join)
Unfortunately, SQLite does not support the RIGHT JOIN clause and also the FULL OUTER JOIN clause. However, you can easily emulate the FULL OUTER JOIN by using the LEFT JOIN clause.
What is natural join in SQLite? In SQLite, the NATURAL JOIN is such a join that performs the same task as an INNER or LEFT JOIN, in which the ON or USING clause refers to all columns that the tables to be joined have in common. A natural join joins two tables by their common column names.
Each join clause determines how SQLite uses data from one table to match with rows in another table. Note that SQLite doesn't directly support the RIGHT JOIN and FULL OUTER JOIN .
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 'FULL
' OUTER JOIN
's are not supported.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With