我有两个表user_roles
,它们将具有rid和uid,即用户ID和角色ID。我想从角色id中提取uid并将其输入到users表中以获取用户6.如何在sql中执行此操作?(我使用phpmyadmin从我正在迁移的项目中提取数据).This是我试过的。
SELECT * FROM `users` WHERE uid =(select uid from `users_roles` where rid= 6 )
答案 0 :(得分:0)
SELECT * FROM `users` WHERE uid in (select uid from `users_roles` where rid= 6 )
答案 1 :(得分:0)
您可以使用JOIN:
SELECT u.* FROM users u
JOIN users_roles ur
ON u.uid=ur.uid
WHERE ur.rid=6