title: subquery returns more than one row error in mysql
body: <p>I have a table which contains a list of users and the apps they are allowed to access. Each row in this table has a column for user_id and app_id along with some other stuff, and the presence of such a row is enough for each user to be able to access that app.</p>
  
  <p>I have some users who can access a particular app already, but I would like to see which users don't have access to a particular app and give them access to this app by creating rows in table for each such user.</p>
  
  <p>It would be something like this:</p>
  
  <pre><code>SET @v1 := (SELECT user_id from user_app_map WHERE app_id != &lt;app_id_here&gt; );
  
  INSERT INTO user_app_map (user_id, app_id) VALUES (
      (SELECT @v1), &lt;app_id_here&gt; );
  </code></pre>
  
  <p>When I'm executing the above query, I am getting <code>#1242 - Subquery returns more than 1 row</code> error.</p>
  
  <p>I have searched for this error on Google, but the results I got had some problem that was more complicated than this one, so I couldn't understand what I wanted from that.</p>
  
  <p>Please tell me how can I do such an operation? </p>
  
  <p>Thanks in advance!</p>
  
  <p>UPDATE: I could have done it this way:</p>
  
  <pre><code>INSERT INTO user_app_map (user_id, app_id)
    SELECT user_id, &lt;app_id_here&gt; from user_app_map WHERE app_id != &lt;app_id_here&gt;
  </code></pre>
  
  <p>but this method will not work in this case, because some users who have access to multiple apps, have many rows in the table with their id. If I query as said above, I would give the same person access to same app again.</p>
  
  <p>Example: user 3 may have access to app 3 and app 4 both, which means user_app_map contains two rows with user_id 3 and app_id 3 and 4 each. With above query, I get user_id from second row, and again create another row, which would be an unnecessary duplicate of first row.</p>