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
Post a Comment