您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

SQLAlchemy如何按多对多子项过滤

SQLAlchemy如何按多对多子项过滤

query = (
    session.query(Post)
           .join(Post.tags)     # It's necessary to join the "children" of Post
           .filter(Post.date_out.between(start_date, end_date))
           # here comes the magic: 
           # you can filter with Tag, even though it was not directly joined)
           .filter(Tag.accepted == 1)
)

免责声明:这是我实际代码的简化示例,在简化过程中可能会犯一个错误

希望对您有所帮助。

SQLServer 2022/1/1 18:53:12 有397人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶