Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

第九章 P402 第一个SQL语句的疑问 #175

Open
guoxy2016 opened this issue May 9, 2019 · 0 comments
Open

第九章 P402 第一个SQL语句的疑问 #175

guoxy2016 opened this issue May 9, 2019 · 0 comments

Comments

@guoxy2016
Copy link

这条SQL语句是不是有问题呀, photo没有tag_id字段, 是不是因该改成SELECT tag.* FROM tag JOIN tagging ON tag.id = tagging.tag_id JOIN photo ON photo.id=tagging.photo_id. 还有一点想问如果我把tagging修改为关联模型, 我是不是可以直接从tagging查找热们标签.而不是用join.大概就是Tagging.query.group_by(tagging.tag_id).order_by(func.count(tagging.photo_id).desc()).limet(10)
之后对查询出来的tagging在模板中分别使用tag关联属性(在建立模型的时候添加relationship)是不是也能实现相同的功能.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant