title: Selecting with subqueries in MySQL (Subqueries with ANY, and IN)
body: <p>Thanks for the great answers!</p>
  
  <p><strong>For More Information</strong></p>
  
  <ul>
  <li><a href="http://dev.mysql.com/doc/refman/5.0/en/comparison-operators.html#function_in" rel="nofollow noreferrer">More info on MySQL IN comparison operator</a></li>
  <li><a href="http://dev.mysql.com/doc/refman/5.0/en/join.html" rel="nofollow noreferrer">Joining Tables</a></li>
  <li><a href="http://dev.mysql.com/doc/refman/5.0/en/any-in-some-subqueries.html" rel="nofollow noreferrer">Subqueries with ANY, IN, and SOME</a></li>
  </ul>
  
  <hr>
  
  <p>This is hard to explain, so lets set the stage...</p>
  
  <pre><code>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! |
  +------+--------+
  </code></pre>
  
  <p>I want to select group a's actions. My idea was to</p>
  
  <pre><code>SELECT actions, user FROM userActions
      WHERE user = (SELECT user, group FROM userGroupMap WHERE group = a)
  </code></pre>
  
  <p>But obviously this subquery returns more than one row. Should I use a JOIN?</p>
  
  <pre><code>Subquery returns more than 1 row
  </code></pre>