Hi Michal > q.join(ReferenceAuthor, ReferenceAuthor.c.Index == 0)
Ah, of course! Thank you very much! But... ;) This Python code return self.session.query(Reference) \ .filter_by(_mark = False) \ .join(Periodical) \ .join(ReferenceAuthor, ReferenceAuthor.c.Index==0) \ .join(Person) \ .order_by(Periodical._name) \ .order_by(Person._lastname) \ .all() The SQL echoed looks ok: SELECT "Reference"."ID" AS "Reference_ID", "Reference"."HasLabel" AS "Reference_HasLabel", "Reference"."PeriodicalID" AS "Reference_PeriodicalID" FROM "Reference" JOIN "Periodical" ON "Periodical"."ID" = "Reference"."PeriodicalID" JOIN "ReferenceAuthor" ON "ReferenceAuthor"."Index" = ? JOIN "Person" ON "Person"."ID" = "ReferenceAuthor"."PersonID" WHERE "Reference"."HasLabel" = 0 ORDER BY "Periodical"."Name", "Person"."LastName" But result doesn't looks like that it is secondary sorted by first persons lastname. See as an example one "Periodical._name" (Bmc Geriatrics) and the first persons lastname of 8 References. Bmc Geriatrics Dapp Tuntland Hsu van der Elst Khatib Hermans van Buul Lichtner -- Verfassungsbeschwerden gegen Vorratsdatenspeicherung <https://digitalcourage.de/weg-mit-vds> Dein Recht zu unterzeichnen! -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at https://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.