Search Postgresql Archives

Re: Different LEFT JOIN results with and without USING

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Alexander Farber <alexander.farber@xxxxxxxxx> writes:
> why do these queries please return different results?

>     FROM    words_scores s
>         LEFT JOIN words_games g ON s.gid = g.gid
>         AND   s.uid = 1

In this one, "s.uid = 1" is part of the LEFT JOIN condition, so it never
eliminates s rows.  Rows not satisfying the condition will be
null-extended instead.

>     FROM    words_scores s
>         LEFT JOIN words_games g USING(gid)
>         WHERE s.uid = 1

In this one, it's part of the top-level WHERE, so it does eliminate s
rows.

			regards, tom lane


-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux