On 3/31/06, sam <[EMAIL PROTECTED]> wrote:

I would like to get help on how to use Django DB API to accomplish the
equivalent of the following SQL statement:

select a from X, Y where X.f = Y.id and Y.c=123;

X has field a, f and Y has field id, c.
f is foreign key of Y and Y's primary key is id.

Its a little difficult without table names, but you're looking for something like:

xs.get_list(f__c__exact=123)

That is, get a list of all X objects where the related object Y, held in relation f, has a member c that is exactly 123. Django will automatically roll out the rest of the join for you.

Hope that helps,
Russ Magee  %-)


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

Reply via email to