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?

Seth


On Aug 28, 12:07 pm, Mike Conley <[email protected]> wrote:
> It works and will probably be OK. Using this style (query for user multiple
> times) in a really big database could lead to a performance problem
> depending on how the underlying database engine constructs a query plan. Try
> it and see how it goes.
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" 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/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to