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" > > How can I append the where clause to a select object?
the key to the message is to view the SQL that is being emitted. it implies a "SELECT" is being rendered in the FROM clause of an enclosing SELECT. 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...). > > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---