sql - Differences between forms of LEFT JOIN -



sql - Differences between forms of LEFT JOIN -

what difference between these query

class="lang-sql prettyprint-override">select a.anyfield left bring together b on b.aid = a.id left bring together c on b.cid = c.id

and query

class="lang-sql prettyprint-override">select a.anyfield left bring together ( b bring together c on b.cid = c.id ) on b.aid = a.id

original answer:

they not same.

for illustration a left bring together b left bring together c homecoming rows, plus b rows if there no c rows.

a left bring together (b bring together c) never homecoming b rows if there no c rows.

added later:

sql>create table (id int); sql>create table b (id int); sql>create table c (id int); sql>insert values (1); sql>insert values (2); sql>insert b values (1); sql>insert b values (1); sql>insert c values (2); sql>insert c values (2); sql>insert c values (2); sql>insert c values (2); sql>select a.id left bring together b on a.id = b.id left bring together c on b.id = c.id; id =========== 1 1 2 3 rows found sql>select a.id left bring together (b bring together c on b.id = c.id) on a.id = b.id; id =========== 1 2 2 rows found

sql

Comments

Popular posts from this blog

Using Android Volley to post an array to PHP -

python - How to add an model instance to a django queryset? -

angularjs - No 'Access-Control-Allow-Origin' error from local domain to public API -