title: MySQL - Delete a selection
body: <p>I am trying to delete all the accounts associated with IPs that are used more than two times in my MyBB database. The following code works to "select" these users.</p>
  
  <pre><code>SELECT * FROM `mybb_forumusers` WHERE `regip` IN (
      SELECT `regip` FROM `mybb_forumusers`
      GROUP BY `regip`
      HAVING COUNT( `regip` ) &gt; 2
  )
  </code></pre>
  
  <p>However, I cannot successfully delete all of these users without getting errors. I have tried the following (and variations):</p>
  
  <pre><code>DELETE FROM `mybb_forumusers` WHERE `uid` IN (
      SELECT `uid` FROM `mybb_forumusers` WHERE `regip`IN (
          SELECT `regip` FROM `mybb_forumusers`
          GROUP BY `regip`
          HAVING COUNT( `regip` ) &gt; 2
      )
  )
  </code></pre>