什么是SQL查询

时间:2017-02-03 04:03:52

标签: mysql node-mysql

我希望通过搜索role.id找出role.name,然后通过匹配他们的user_id = founded role.id

来检索所有用户

enter image description here

2 个答案:

答案 0 :(得分:1)

以下查询将有效:

select id,user_id,username from (select id from Role where name = 'provider') as t
join
user u on t.id = u.role

答案 1 :(得分:0)

SELECT * FROM users INNER JOIN role on user.role  = role.id WHERE role.name = 'provider'