英文:
web2py: left-outer join not giving all records on left
问题
This code is not returning groups with zero (0) count.
(这段代码没有返回计数为零的组。)
英文:
Why is this code not returning groups with zero (0) count? (I am sure there are groups with zero count)
count = db.auth_membership.id.count()
groups = db().select(db.auth_membership.group_id, db.auth_group.role, count,
left=db.auth_group.on(db.auth_membership.group_id==db.auth_group.id),
groupby=db.auth_membership.group_id)
答案1
得分: 0
I finally got it. Here's the query that worked:
query = db.auth_membership.group_id == db.auth_group.id
count = db.auth_membership.id.count()
groups = db(db.auth_group).select(db.auth_group.id, db.auth_group.role, db.auth_membership.id,
count,
groupby=db.auth_group.id,
left=db.auth_membership.on(query))
英文:
edited
I finally got it. Here's the query that worked:
query = db.auth_membership.group_id == db.auth_group.id
count = db.auth_membership.id.count()
groups = db(db.auth_group).select(db.auth_group.id, db.auth_group.role, db.auth_membership.id,
count,
groupby=db.auth_group.id,
left=db.auth_membership.on(query))
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论