title: MySql: Delete from table with join
body: <p>I need to delete records from a child table (<code>table_b</code>) based on the status of matching records in the parent table (<code>table_a</code>).  Something like this:</p>
  
  <pre><code>delete from table_b b inner join table_a a on b.user_id = a.id where a.status = 0;
  </code></pre>
  
  <p>But MySql says there is an error in the syntax.</p>
  
  <p>I also tried the following:</p>
  
  <pre><code>delete from table_b where user_id in (
    select id from table_a a inner join table_b b on a.id = b.user_id 
    where a.status = 0)
  </code></pre>
  
  <p>But evidently I cannot specify a table for update and simultaneously include it in the <code>FROM</code> clause.</p>
  
  <p>What's the correct way to do this?</p>