title: How can I delete all rows within a table in a mysql database, which value = 0 for one of the columns?
body: <p>So basically, it's like this:</p>
  <p>The table is called <code>phpbb_posts</code></p>
  <p>The column name is <code>post_approved</code></p>
  <p>I want to run a query which deletes all rows in <code>phpbb_posts</code> table in which the <code>post_approved</code> value is 0 (All rows contain either a 1 or a 0 value for the column <code>post_approved</code>)</p>
  <p>I wanted to make sure I am running the correct query, before running it.</p>
  <pre><code>DELETE FROM phpbb_posts
  WHERE EXISTS(
                SELECT * 
                FROM phpbb_posts
                WHERE (post_approved = 0) 
              )
  </code></pre>
  <p>Please tell me if this code is correct; or if it is wrong, please tell me the correct code.</p>
  <hr>
  <hr>
  <p>CODE FIXED (thanks!):</p>
  <pre><code>DELETE FROM phpbb_posts WHERE post_approved = 0
  </code></pre>
  <p><strong>RESULT:</strong></p>
  <pre><code>35743 rows deleted. ( Query took 1.3562 sec )
  </code></pre>
  <blockquote>
  <p><em>P.S. FOR THOSE WONDERING, THIS REMOVES ALL SPAM POSTS FROM PHPBB IN
  ONE FELL SWOOP! (assuming you don't have any valid posts you want to
  approve). Instead of going through moderator and &quot;disapproving&quot; for
  50,000 pages, you can do this! :) :)
  and yes I checked in the moderator queue and all the spam posts i never approved are gone! YAY!</em></p>
  </blockquote>