On May 28, 10:59 pm, Boris Shemigon <shemi...@gmail.com> wrote:
> Hi,
>
> I wonder is there a way to generate a query with joins with more than one
> condition? For example:
>
> SELECT o.id FROM object
> JOIN object_value AS ov1 ON ov1.o_id=object.id AND ov1.field_id=1 AND
> ov1.value=2
> JOIN object_value AS ov2 ON ov2.o_id=object.id AND ov2.field_id=2 AND
> ov2.value>=1
> JOIN object_value AS ov3 ON ov3.o_id=object.id AND ov3.field_id=3 AND
> ov3.value>=2
>
> It's supposed to find all objects that have all fields with corresponding
> values.
>
> Does anybody know how to code that in the frame of Django ORM. Or the only
> solution is to go down to SQL?

There is currently no way to add conditions to the join clause, not
even by using internal APIs.

 - Anssi

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to