We don't need the first query for fetching books. All data about book available from BookSequence too. And all filters you apply to books, you can apply to BookSequence via book__ filter. Again, from my first example, and using just one query
bs = BookSequence.objects.filter(book__title__startswith='Hello'). select_related() for s in bs: print s.sequence.name, s.number_in_sequence, *s.book.title* 2011/5/1 А. Р. <4d876...@gmail.com> > I just wonder if it is possible to get data from those three tables in > one sql query using django. > So far we have two queries, one fetching data from the `book` table > (title etc.), and after that the > second fetching sequences (genres, etc.) for this book. > > I don't at all mind it be two separate queries, just curiosity. > > -- 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+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.