On Wed, 22 Mar 2017 10:53:09 -0500
Jeffrey Mattox <j...@mac.com> wrote:

> Isn't it possible to get the same results of a RIGHT JOIN by using
> two selects with a UNION or UNION ALL between them.

Yes.  By definition, an outer join is the union of

        the rows that meet the matching criteria
and
        the rows that do not meet the matching criteria
        
The outer join construct exists for convenience: the convenience of the
user, who expresses the idea with fewer words, and the convenience of
the implementer, whose query optimization problem is simplified by the
direct expression of the desired result.  

An outer join says explicitly it wants all rows in the outer table.  On
the other hand, the query planner has to be quite sophisticated to
recognize that 

        A = (A where exists B)  union (A where not exists B)

--jkl
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to