On Nov 10, 12:46 pm, "Michael Bayer" <mike...@zzzcomputing.com> wrote:
> Bryan wrote:
>
> > Trying to append this to a select object:
> > "WHERE jobId IN (SELECT id FROM job WHERE number=11111)"
>
> > So I do this:
> > query = select(<Bunch of stuff including a `jobId` column>)
> > subq = select([job.c.id], job.c.number==11111).as_scalar()
> > query = query.where(query.c.jobId.in_(subq))
>
> > But that is not working: "Every derived table must have its own alias"

>It's probably because you're pulling the "jobId" column of your
> outer SELECT statement and sticking it inside the WHERE clause of that
> statement (query.where(query.c.jobId...).

I changed query.where(query.c.jobId... to query.where(column
("jobId")...
and that seems to be working.

Why can't I refer to a column with query.c at this point?  The query
already has columns in its c collection, and I don't want to have
repeat string names of columns, it would be cleaner to say
query.c.jobId than "jobId".  I thought that query.c.jobId would simply
generate "jobId" when the sql was generated.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to