Search code examples
mysqlsqljoinsql-delete

Delete entries in one table where value is equal to one in second table


What I want to do is something like a JOIN but not to get a result in this case: I have a table A containing

idx | values

and a table B containing

idx | A_idx | values

Now I want to delete all these rows in A where A.idx is equal to B.A_idx. Any idea how this can be done?


Solution

  • Try this

    delete from table a
    where IDX in (select a_idx from table b)