On 8/31/06, MrTufty <[EMAIL PROTECTED]> wrote:
> The SQL I have managed to write to get the permissions for the
> usergroups that a user is part of is this, for anyone who is
> interested:
>
> SELECT permissions, type
> FROM permissions
> LEFT JOIN usergroups_permissions
> ON usergroups_permissions.permission_id = permissions.id
> WHERE usergroups_permissions.usergroup_id
> IN (
> SELECT usergroup_id
> FROM users_usergroups
> WHERE users_usergroups.user_id = ?
> );
>
> I could probably achieve everything I want to do with a UNION, but I
> havent yet looked into that, and from what I have read, theyre rather
> slow....

Why the subquery?

select p.permission
, up.type
from permissions p
, usergroups_permissions up
, users_usergroups uu
where p.id = up.permission_id
and up.usergroup_id = uu.usergroup_id
and uu.user_id = ?


Regards,

Martin

-- 
  Martin Schapendonk, [EMAIL PROTECTED]

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~----------~----~----~----~------~----~------~--~---

Reply via email to