I want to use union on two queries, which have different order:
q1 = Thing.query().order_by(Thing.a)
q2 = Thing.query().order_by(Thing.b)
q = q1.union(q2).all()

But after this query I get MySQL error message "Incorrect usage of
UNION and ORDER BY".

I guess that this could be because having "SELECT ... UNION SELECT ...
ORDER BY B", it is not clear whether the second subquery or both
queries should be ordered using B criteria. I think this can be solved
by adding brackets to each of the subquery: "(SELECT ...) UNION
(SELECT ...)".

Is there any way to create this query using SQLAlchemy ORM?

I am using SQLAlchemy 0.5.4.
--~--~---------~--~----~------------~-------~--~----~
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