Djangoids:

Consider this QuerySet:

   Blog.objects.filter(comment__date__range=(self.yesterday,
self.tomorrow))

It returns all the blogs with any comment (as a side note, it seems to
return each blog redundantly, to allow the SELECT to differ each
returned row by comment).

I need every Blog whose first comment appears in the date range:

SELECT * FROM blog
 INNER JOIN comment ON comment.blog_id = blog.id
WHERE MIN(comment.date) BETWEEN '2010-09-12' AND '2010-09-14'
GROUP BY(blog.id)

Can I get that without dropping to raw SQL?

--
  Phlip
  http://zeekland.zeroplayer.com/

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

Reply via email to