Re: or-ing to QuerySets turns INNER into LEFT OUTER joins?
Hi Tom,
thank you very much for your reply!
Am 25.07.2013 12:17, schrieb Tom Evans:
> Isn't this to be expected? You've asked Django to OR the querysets.
> This means that you are looking for tuples from STAFF where either the
> join+conditions to ERFASST match or the join+conditions to
> STAFF_BEREICHE match. If these joins were performed with an INNER
> JOIN, then the query would only include tuples from STAFF that match
> both joins and conditions.
Well, I must foreclose that I'm by no means an SQL expert, and rather
consider myself as a beginner -- but won't the joins augment the STAFF
table independently of each other?
That is, if I understand things correctly, the join types INNER vs. LEFT
OUTER are mostly about the handling of NULL values on the "other" side
of the relation, but as only non-NULL values are involved here, I'd
expect a query to provide the same augmented table no matter if INNER or
LEFT OUTER joins are used.
(And vice versa, as the corresponding Django foreign key fields are
defined as non-NULL, too, I thought that Django would use INNER joins in
the first place.)
The OR in the WHERE clause then acts "independently" on the resulting
augmented table.
When I try this experimentally with the queries Q_a and Q_b from my
original post, where Q_a and Q_b yield different result tuples, e.g.
A B C D E
for Q_a and
D E F G
for Q_b, then *both* the query Q_a_or_b with the original LEFT OUTER
joins, as well as an edited query where INNER join is used instead,
yield the same result tuple set
A B C D E F G
Or is my understanding of SQL basics that wrong?
Best regards,
Carsten
--
Dipl.-Inf. Carsten Fuchs
Carsten Fuchs Software
Industriegebiet 3, c/o Rofu, 55768 Hoppstädten-Weiersbach, Germany
Internet: http://www.cafu.de | E-Mail: info@cafu.de
Cafu - the open-source game and graphics engine for multiplayer 3D action
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home