-3

i want to Find out role.id by searching role.name and then retrieve all users by matching their user_id = founded role.id

2 Answers2

1

Below query will work:

select id,user_id,username from (select id from Role where name = 'provider') as t
join
user u on t.id = u.role
Nisse Engström
  • 4,738
  • 23
  • 27
  • 42
Chintan Udeshi
  • 362
  • 1
  • 8
0
SELECT * FROM users INNER JOIN role on user.role  = role.id WHERE role.name = 'provider'
  • 1
    When giving an answer it is preferable to give [some explanation as to WHY your answer](http://stackoverflow.com/help/how-to-answer) is the one. – Stephen Rauch Feb 03 '17 at 16:43