I think you have to use group by with a count(). Something like

Account.query.join(Account.users).group_by(Account.id).filter(func.count(User.id)
> 1)

On Mon, Jan 26, 2009 at 12:59 PM, Jon Nelson <jnel...@jamponi.net> wrote:
>
> Let's assume I have a 1:many relationship between Accounts and Users.
>
> What I want (for example) is a list of Accounts with > 1 User.
>
> Ideally, I'd do this:
>
> Account.query().filter( len(Account.users) > 1 ).all()
>
> but of course that doesn't work.
>
> Instead of describing the myriad ways I've tried, I thought I'd ask instead:
>
> What's the easiest/best way to go about that without lots of hoop-jumping?
>
> I'm using 0.5.2
>
> --
> Jon
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to