Thanks Michael, jlc
On Tue, Nov 26, 2013 at 9:34 PM, Michael Bayer <mike...@zzzcomputing.com>wrote: > > On Nov 26, 2013, at 7:45 AM, Joseph Casale <jcas...@gmail.com> wrote: > > > I have a scalar sub query with a predicate that involves a table and > column produced in the > > outer query, Company.id for example. > > this is called a correlated subquery. > > > > The only way I could include the query was to write > > it out literally and add it as a column with literal_column. > > > > query = session.query(Company, City, <...>, literal_column(sub)).\ > > join(City).\ > > join(<...>).\ > > filter(<...>) > > ... > > > > I have the sub query written using the actual table classes etc, but > could not find a way to > > include the non text representation of the sql statement (sub) into the > outer query. > > you build up your subquery normally, then you can inject it as a column > using as_scalar(), some background is at > http://docs.sqlalchemy.org/en/rel_0_9/core/tutorial.html#scalar-selects > > > -- 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 http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/groups/opt_out.