感谢您的精彩回答!
了解更多信息
这很难解释,所以让我们设置舞台......
userActions userGroupMap
+------+--------+ +------+-------+
| user | action | | user | group |
+------+--------+ +------+-------+
| x | acted! | | x | a |
| y | acted! | | y | a |
| y | acted! | | z | b |
| z | acted! | +------+-------+
| y | acted! |
| z | acted! |
| x | acted! |
| z | acted! |
+------+--------+
我想选择组 a 的操作。我的想法是
SELECT actions, user FROM userActions
WHERE user = (SELECT user, group FROM userGroupMap WHERE group = a)
但显然这个子查询返回不止一行。我应该使用 JOIN 吗?
Subquery returns more than 1 row