This should do it.

current_user_id=...
db((db.users.id==db.user_tags.user_id)&(db.user_tags.tag_id==db.tag.id)
&(db.user_tags.tag_id.belongs(db
(db.user_tags.user_id==current_user_id)._select
(db.user_tags.tag_id)))).select
(db.users.ALL,db.tag.ALL,groupby=db.users.id)

Massimo

On Jun 6, 2:54 pm, Jason Brower <encomp...@gmail.com> wrote:
> I have a big fat book on SQL syntax.  But I am hoping on using Web2Py's
> python syntax.
> I want to make it so my users that have tags that are the same can be
> listed with the tag is the same between them.  The user I am looking up
> is the logged in user, I am using the auth feature.
> Soo  I have tag "One" and Billy has tag "One" so I want to be able to
> see that user "billy" has the tag "One" that I do.
> Hope that explains it.
> I have the following relevent tables...
> ------
> db.define_table('users',
>         SQLField('first_name', 'string', length=15),
>         SQLField('last_name', 'string', length=15),
>         SQLField('phone_number', 'string', length=15),
>         SQLField('email', 'string'),
>         SQLField('password', 'password'),
>         SQLField('university_affiliation', 'string', length=25),
>         SQLField('created', 'datetime', default=now, readable=False,
> writable=False),
>         SQLField('registration_key', length=128, writable=False,
> readable=False, default=''),
>         SQLField('avatar', 'upload'),
>         SQLField('short_description','text'))
>
> db.define_table('tag',
>         SQLField('name', 'string'),
>         SQLField('description', 'text'),
>         SQLField('logo', 'upload'),
>         SQLField('created', 'date', default=now, writable=False),
>         SQLField('creator', 'string', writable=False))
>
> db.define_table('user_tags',
>         SQLField('tag_id',db.tag),
>         SQLField('user_id',db.users))
>
> db.user_tags.tag_id.requires = IS_IN_DB(db,'tag.id')
> db.user_tags.user_id.requires = IS_IN_DB(db,'users.id')
>
> db.users.first_name.requires = IS_NOT_EMPTY()
> db.users.last_name.requires = IS_NOT_EMPTY()
> db.users.password.requires = CRYPT()
> db.users.email.requires = [IS_EMAIL(), IS_NOT_IN_DB(db,'users.email')]
> db.users.created.requires = IS_NOT_EMPTY()
> ----
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to