我这里有两张表,一张是主表(估且这样叫吧),另一张是从主表中找出来的一些数据(叫子表吧)
我想把主表的一些数据删除,条件是这些数据都是子表中的.请问这样怎么做?谢谢哈.有确定答案后闪电结贴^-^

解决方案 »

  1.   

    delete from 主表 where id in(select id from 子表)或者delete from 主表 where 子表的查询条件
      

  2.   


    delete 主表 from 主表 a where exists(select 1 from 子表 where 子表字段=a.字段)
      

  3.   

    有没有ID,
    delete from tb where id in (select id from tb1)
      

  4.   

    delete from maintable
    where exists (select 1 from subtable
      where maintable.id=subtable.id)delete from maintable
    where exists (select 1 from subtable where 1=1 
      and maintable.field1=subtable.field1
      and maintable.field2=subtable.field2
      and maintable.field3=subtable.field3
      and maintable.field4=subtable.field4)
      

  5.   

    delete [主表] from [主表] a where exists(select 1 from [子表] where [子表].关连字段=a.关连字段)
      

  6.   

    select 1 from subtable,请问下这个1是什么意思?
      

  7.   

    select 1 是检查表中符合条件的数据