Hi
At:
http://docs.djangoproject.com/en/dev/topics/db/queries/#spanning-multi-valued-relationships
there is written:
"That may sound a bit confusing, so hopefully an example will clarify.
To select all blogs that contains entries with "Lennon" in the headline
and were published in 2008, we would write:
Blog.objects.filter(entry__headline__contains='Lennon',
entry__pub_date__year=2008)
To select all blogs that contain an entry with "Lennon" in the headline
as well as an entry that was published in 2008, we would write:
Blog.objects.filter(entry__headline__contains='Lennon').filter(
entry__pub_date__year=2008)
In this second example, the first filter restricted the queryset to all
those blogs linked to that particular type of entry. The second filter
restricted the set of blogs further to those that are also linked to the
second type of entry. The entries select by the second filter may or may
not be the same as the entries in the first filter. We are filtering the
Blog items with each filter statement, not the Entry items.
"
I've got the following questions: how will these two examples will
translate into SQL? I don't understeand why these two may give different
results. The second example in my mind should work this way: all blogs
that have headline containing 'Lennon' will be filtered to find those
whose have at least one entry that has pub_date = 2008.
Sincerely,
Marek
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---