Join on a CTE in SQLAlchemy
问题 I'm trying to formulate a SQLAlchemy query that uses a CTE to build a table-like structure of an input list of tuples, and JOIN it with one of my tables (backend DB is Postgres). Conceptually, it would look like: WITH to_compare AS ( SELECT * FROM ( VALUES (1, 'flimflam'), (2, 'fimblefamble'), (3, 'pigglywiggly'), (4, 'beepboop') -- repeat for a couple dozen or hundred rows ) AS t (field1, field2) ) SELECT b.field1, b.field2, b.field3 FROM my_model b JOIN to_compare c ON (c.field1 = b.field1)