sql - Get Roles which are still not assigned to member query -


how query mysql database return roles still not assigned (like available him).

with table user_roles:

|user_id|role_id| |   1   |   1   | |   1   |   2   |  |   1   |   4   | |   1   |   7   | 

how can query roles table return role name , id of roles not assigned. role_id: 3,5,8,...

try

select * roles r not exists (    select 1    user_roles ur    ur.role_id = r.id    , ur.user_id = 1 ) 

Comments

Popular posts from this blog

unicode - Are email addresses allowed to contain non-alphanumeric characters? -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

c++ - Convert big endian to little endian when reading from a binary file -