Groups
Groups
Sign in
Groups
Groups
Django users
Conversations
About
Send feedback
Help
Set additional conditions for JOIN
8 views
Skip to first unread message
Boris Shemigon
unread,
May 28, 2012, 3:59:39 PM
5/28/12
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to django...@googlegroups.com
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?
akaariai
unread,
May 28, 2012, 4:18:51 PM
5/28/12
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Django users
There is currently no way to add conditions to the join clause, not
even by using internal APIs.
- Anssi
Reply all
Reply to author
Forward
0 new messages