I'm trying to join a table with its children's children. I have this relationship: store->department->employee where a store has many departments and each department has many employees. How can I make it such that I have a table with store and employee joined together? Can I achieve this in flask/sqlalchemy? (similar to this laravel "has many through" relationship: https://laravel.com/docs/4.2/eloquent#polymorphic-relations)
Asked
Active
Viewed 163 times
1
-
Possible duplicate of [sqlalchemy: how to join several tables by one query?](http://stackoverflow.com/questions/6044309/sqlalchemy-how-to-join-several-tables-by-one-query) – doru Jan 31 '16 at 17:26
-
that was one of the results that I saw. The second answer was: query = session.query(User, Document, DocumentsPermissions).join(Document).join(DocumentsPermissions).all() Now, what if I want all documentsPermissions for a user? Something like query.filter(User.id == 2).documentsPermission where I want a user with id == 2 and fetch me all of his/her document permission regardless of where each document maps to each permission? – raffy4284 Jan 31 '16 at 21:16