0

I need to delete records from a child table (table_b) based on the status of matching records in the parent table (table_a). Something like this:

delete from table_b b inner join table_a a on b.user_id = a.id where a.status = 0;

But MySql says there is an error in the syntax.

I also tried the following:

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)

But evidently I cannot specify a table for update and simultaneously include it in the FROM clause.

What's the correct way to do this?

DatsunBing
  • 8,684
  • 17
  • 87
  • 172

0 Answers0