General question about NOT EXISTS...
This is a generic question because I am a newbie and things are not
gelling quite 100% on how to write Q statements to get a filter to do
everything one wants.
Let's say you have Table A and Table B and Table C, where Table B has
a foreign key to table A and Table C (a manually constructed many to
many because it has extra data elements)
Now I want to build a list of all elements from table A, where not
exists a record in Table B that is related to table A and also has a
couple values = to something, and related to a particular table C
record)
In SQL this would look like:
select * from a where not exists (select * from B,C where
a.id=b.aforeignkey and c.id=b.cforeignkey and b.filter1=blah and
c.filter2=blah)
How does that look when you are building an object list in the Q( )...
style format? Where I am hung up is finding syntax examples of how to
do the functional equivalent of a sql where not exists clause.
Is there a way to do this without using .extra() and using just normal
django?
-Wes Wagner
--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home