Re: [web2py] Re: I think I need to make a join on a many to many... getting complicated for me...

2011-04-14 Thread howesc
jason, you will need to join in the user table and adjust your grouping accordingly. somthing like: 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.use

Re: [web2py] Re: I think I need to make a join on a many to many... getting complicated for me...

2011-04-14 Thread Jason Brower
I still can't get the user's information out of this query. How would I do that? BR, Jason On 04/15/2011 06:22 AM, Jason Brower wrote: 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

Re: [web2py] Re: I think I need to make a join on a many to many... getting complicated for me...

2011-04-14 Thread Jason Brower
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) in

[web2py] Re: I think I need to make a join on a many to many... getting complicated for me...

2011-04-14 Thread Massimo Di Pierro
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 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 o

Re: [web2py] Re: I think I need to make a join on a many to many... getting complicated for me...

2011-04-14 Thread Jason Brower
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 discussi

Re: [web2py] Re: I think I need to make a join on a many to many... getting complicated for me...

2011-04-13 Thread ron_m
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

Re: [web2py] Re: I think I need to make a join on a many to many... getting complicated for me...

2011-04-13 Thread Jason Brower
I made it fit my tables better: count = db.users_tags.id.count() query = db((db.users_tags.user != auth.user.id) & #<--- that is a join (db.users_tags.tag.belongs(db(db.users_tags.user==auth.user.id)._select( #<--- I thought select was only used at the end when you do

[web2py] Re: I think I need to make a join on a many to many... getting complicated for me...

2011-04-13 Thread howesc
untested but... If i where to write raw SQL, i think this is what you are asking for (where auth.user.id==42): SELECT ut.user, count(*) FROM users_tags ut WHERE ut.user != 42 AND ut.tag IN (SELECT tag FROM user_tags WHERE user=42) GROUP BY ut.user ORDER BY count(*) and i think this transl

[web2py] Re: I think I need to make a join on a many to many... getting complicated for me...

2011-04-13 Thread pbreit
Like this? http://web2py.com/book/default/chapter/06?search=distinct#Grouping-and-Counting