On Sep 9, 2009, at 8:41 PM, Seth wrote:

>
> Ok Mike,
>
> Tell me what you think about this:
>
> q1 = DBSession.query(P1.id, P1.user_id, P1.type, P1.title, P1.body,
> P1.created, P1.updated)
> q2 = DBSession.query(P2.id, P2.user_id, "'P2'", P2.title, P2.body,
> P2.created, P2.updated)
> q3 = DBSession.query(P3.id, P3.user_id, "'P3'", P3.title, P3.body,
> P3.created, P3.updated)
>
> subquery = DBSession.query().from_statement(union_all(q1, q2,
> q3)).subquery()
>
> posts = DBSession.query(subquery, User.name).filter
> (User.user_id==subquery.c.user_id)
>
>
> Kind of hackish, but... it seems to work?

you should be able to call select() directly on the union_all() and  
send that as your subquery.


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