Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What joins does SQLite support?

Tags:

join

sqlite

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?

like image 363
Andrey Fedorov Avatar asked Apr 21 '09 20:04

Andrey Fedorov


People also ask

Does SQLite have join?

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)

Does SQLite support full 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.

Does SQLite support natural join?

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.

Which 2 types of join operations are not supported by SQLite?

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 .


1 Answers

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.

like image 59
4 revs Avatar answered Nov 10 '22 14:11

4 revs