MySQL- complex data query in a single statement

Posted by yoda on Stack Overflow See other posts from Stack Overflow or by yoda
Published on 2010-06-08T14:28:16Z Indexed on 2010/06/08 14:32 UTC
Read the original article Hit count: 204

Filed under:
|

Hi,

Consider the following structure :

alt text

Ignore the table user_token.

Now, imagine that you need to get all the roles related to an user, wich may be through it's related groups or directly related to him. In case the same role appears related to a group and the user directly, the role related to the user will prevail over the role given by the group.

Is there any chance this could be done in a single query?

Cheers!

© Stack Overflow or respective owner

Related posts about sql

Related posts about mysql