Sqlalchemy in_ subquery

前端 未结 2 1202
無奈伤痛
無奈伤痛 2021-02-20 12:52

I am trying to implement a select with a nested select clause, to find parents without any children. My tables (radically simplified) are as follows:

class Pers         


        
2条回答
  •  我在风中等你
    2021-02-20 12:58

    Join worked for me. Thank you. In my case I was trying to find all ordered objects (Topics) which belong to a particular customer. I have 3 tables Customer, Order, Topics

    stmt = db.session.query(Topics).outerjoin(Order).\
        filter(Order.cust_id == id)
    
    topics = stmt.all()
    

提交回复
热议问题