15
Views
1
Comments
Solved
SQL Roles

I am trying to write a SQL Query to get all users but that are from a specific role that is passed as an Input parameter, but I don't find any possibility to get a research of all Roles
Is there any possibility or not ?
Should I create a table where are cloned all the roles present ?




Solution

Hello Omar,

If your input parameter is Role name so you will need to join user entity with User_Role entity with Role entity and you condition that Role.Name = @role

If your parameter is Id of role you will need to join with User_Role entity only and you condition will be User_Role.RoleId= @Role

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.