SQLite Forum

LEFT JOIN Misunderstanding
Login
Methinks you know not what an equijoin (inner join) is.

An equijoin is a projection (join) of two tables where some item in one table is equal to some item in another table.

SELECT * FROM A, B WHERE A.X == B.X;

is an equijoin of tables A and B.

An outer join is one where all rows of one (or both) tables are included in the projection (LEFT, RIGHT, or FULL (meaning both)) in the projection and the values projected from the other table are NULL if no match is found.

SELECT * FROM A LEFT OUTER JOIN B ON A.X == B.X;

produces the same projection columns, but includes ALL rows from table A, even those where no matching row exists in table B, by setting all such projection results from table B to NULL in that instant.

SELECT * FROM A LEFT OUTER JOIN B ON A.X == B.X WHERE B.X IS NOT NULL;

is the same as 

SELECT * FROM A, B WHERE A.X == B.X;

Pre the invasion of "The Great Unwashed" one would specify

SELECT * FROM A LEFT JOIN B ON A.X == B.X;

Used to be spoken as

SELECT * FROM A, B WHERE A.X *= B.X;

but this was confusing to the children.  Hence the SQL syntax was expanded to permit the use of an ON clause because "think of the children" so that the children could better understand OUTER joins.  The ON clause is ONLY meaningful in OUTER join contexts.  It is useless for INNER joins and serves no useful purpose whatsoever.