On 10/16/07, Rufman <[EMAIL PROTECTED]> wrote:
>
> in SQL terms this is what i want to do:
> SELECT *
> FROM `build`
> WHERE `iKeyBuildNr`
>     IN (
>
>        SELECT `iFKeyBuildNr`
>        FROM `package`
>        WHERE `strPackageName`
>           IN ("denon_AVR4306")
>    )
>
> How can i do this with the django db api? I tried it with __in, but it
> doesn't seem to take QuerSets.

You can't, at least not in one query.

The nearest would be something like this:
iKeys = [p['iFKeyBuildNr'] for p in
            Package.objects.filter(strPackageName__in=['denon_AVR4306']
                                   ).values('iFKeyBuildNr')]
builds = Build.objects.filter(iKeyBuildNr__in=iKeys)

There are several variations on that theme, but I'm pretty sure it'll
require 2 queries if you really need the nested in.

--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to