On 1/22/07, Chris Brand <[EMAIL PROTECTED]> wrote:
> I have an app with Applications, each of which is for a single Camp.
> What I want to do is retrieve all the Camps for which there exists an
> Application.

The straightforward way is to retrieve a list of distinct values for
'camp_id' from the Application table, and then grab the corresponding
Camp objects for that list. In SQL the query would look something like
this (allowing for DB variations):

SELECT * FROM camps where id in (SELECT DISTINCT camp_id FROM application);

You might be able to do this with the 'extra' method of a QuerySet, by
putting the 'where' clause with subselect into the 'where' keyword
argument to extra(), but I haven't tested that to be certain.

-- 
"May the forces of evil become confused on the way to your house."
  -- George Carlin

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to