美文网首页
多表关联查询

多表关联查询

作者: 晓函 | 来源:发表于2016-09-03 21:38 被阅读92次

一个热门文章分类,需要查询所有文章,过滤条件就是该文章所属分类允许被推到热门

首先通过cateid将Post表和Category表拼接起来,然后再判断是否可以推到hot

query = community.posts.join(Community_Category,Community_Category.id==Post.category_id).filter(Community_Category.be_hot==1)

相关文章

网友评论

      本文标题:多表关联查询

      本文链接:https://www.haomeiwen.com/subject/rpxlettx.html