On Dec 19, 6:20 pm, Tim Sawyer <list.dja...@calidris.co.uk> wrote:
> I think so, yes. Something like this: > > You can then do something like > > anObjectA = ObjectA.objects.filter(id=1)[0] > objectBs = ObjectB.objects.filter(object_a=anObjectA) This requires 2 separate queries, right? I'm hoping to just have 1 trip to the DB. > You could do this instead to avoid the anObjectA instance: > > objectBs = ObjectB.objects.filter(object_a__id=1) > > Hope that helps. I'm a bit confused by what you're selecting in: > > > SELECT * FROM TableA JOIN TableB ON TableA.id=TableB.some_id > > WHERE TableA.id=1 > > What are you hoping to have returned? I'm hoping to return the record from TableA with id=1 as well as all the records from TableB with some_id=1. Did I do that the wrong way? An example would be in an auctioning system, return the details of the auction with id=1 and all the bids that have auction_id=1 -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.