SELECT *
FROM Residents
WHERE apartment_id IN (SELECT ID
FROM Apartments
WHERE postcode = 2000)
I'm using sqlalchemy and am trying to execute the above query. I haven't been able to execute it as raw SQL using db.engine.execute(sql)
since it complains that my relations doesn't exist... But I succesfully query my database using this format: session.Query(Residents).filter_by(???)
.
I cant not figure out how to build my wanted query with this format, though.