MYSQL中有一mybase数据库,数据库中有两张表,A表与B表。但是B表的数据在A表都能查询得到。现在想把A表中与B表相同的数据都删除,请问这个SQL语句要如何写?

解决方案 »

  1.   

    delete from a where id in(select id from b);
      

  2.   

    我的删除语句是要两个条件的,一个是要id相同,一个是name相同
    语句改成这样delete from a where id,name in(select id,name from b);就语句错误了
      

  3.   

    delete a from a inner join b on a.id=b.id and a.name=b.name
      

  4.   

    delete from a where exsits (select 1 from b where a.id = b.id);
      

  5.   

    delete from a where id in(select * from b);

    delete from a
    inner join b on a.id=b.id and a.name=b.name;