because that is what group by in sql does.
On Nov 7, 2:56 pm, "Yarko T" <[EMAIL PROTECTED]> wrote:
> explain more..... I see having.itemtype.count() > 1 returns the LAST items
> of type 'blog' and 'dig' (item 'link' has only one, so doesn't meet the
> 'having' criteria).
> But why does it only return one of these items (and not all)?
>
> On Fri, Nov 7, 2008 at 2:35 PM, mdipierro <[EMAIL PROTECTED]> wrote:
>
> > Inspired by this:
> >http://www.eflorenzano.com/blog/post/secrets-django-orm/
>
> > I implemented "having" in the web2py DAL. In trunk only. Here is the
> > web2py way:
>
> > >>> db=SQLDB()
> > >>> db.define_table('TumbleItem',SQLField('title'),SQLField('item_type'))
> > >>> for t,p in [('Blog Post 1','blog'),('Blog Post 2','blog'),('Blog Post
> > 3','blog'),('ArticleDug 1','digg'),('Article Dugg 2','digg'),('Link
> > Saved','link')]: db.TumbleItem.insert(title=t,item_type=p)
> > >>> for row in
> > db().select(db.TumbleItem.ALL,groupby=db.TumbleItem.item_type,having=db.TumbleItem.item_type.count()>1):
> > print row
>
> > Output:
>
> > <SQLStorage {'update_record': <function <lambda> at 0x25ed4f0>,
> > 'item_type': 'blog', 'id': 3, 'title': 'Blog Post 3'}>
> > <SQLStorage {'update_record': <function <lambda> at 0x25ed6f0>,
> > 'item_type': 'digg', 'id': 5, 'title': 'Article Dugg 2'}>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web2py Web Framework" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---