Actually I think the correct way is
(db.users_tags.user != auth.user.id
Because I want all possible users but me. I am still learning this, but
I think that's what it does.
BR,
Jason
On 04/14/2011 09:06 PM, Massimo Di Pierro wrote:
I think you want
(db.users_tags.user != db.auth_user.id)
instead of
(db.users_tags.user != auth.user.id
On Apr 14, 12:05 pm, Jason Brower<encomp...@gmail.com> wrote:
On 04/14/2011 08:46 AM, ron_m wrote:> The _select is a nested select - the one
in the second half of the
WHERE clause that Christian wrote out for the SQL equivalent.
But the _select needs to return exactly one column, try changing
_select() to _select(db.user_tags.tag)
There is some discussion in the manual under the belongs topic
Ron
I see a bit better now, and it kind of works.
{'users_tags': {'user': 1}, '_extra': {'COUNT(users_tags.id)': 1}}
{'users_tags': {'user': 3}, '_extra': {'COUNT(users_tags.id)': 2}}
This represents one user having a relation on tags between two users,
very cool, but I want the users information, and doing a query on each
user is the inefficient way to do it right? I should join them, and I
know how to do that, but this one, I have no idea.
count = db.users_tags.id.count()
query = db((db.users_tags.user != auth.user.id)& #\/-- isn't
that the join?
(db.users_tags.tag.belongs(db(db.users_tags.user==auth.user.id)._select(db.
users_tags.tag))))
#/\--- Right
there?
rows = query.select(db.users_tags.user,
count,
groupby=db.users_tags.user,
orderby=count)
for row in rows:
print row.as_dict()
Best Regards,
Jason