我有两个标A,B。其中B表中的一条记录其中的一个字段D与A表中的字段C内容相同,怎样可以删除A表中的这条记录。

解决方案 »

  1.   

    delete from a where a.c in (select d from b)
      

  2.   

    我的两个字段是 ntext类型的好像不能这样写
      

  3.   

    不对应该是A表的C字段包含B表的D字段,就删除A表中的这条记录
      

  4.   

    ntext  是什么类型 ? 为什么不行??
      

  5.   

    网上查要改成nvarchar(MAX)类型的 但是我 问题问错了该是A表的C字段包含B表的D字段,就删除A表中的这条记录
      

  6.   

    如果建立关联的时候,必须先删除从表,后删除主表信息需要写2个删除语句
    delete from b where id=@id 
    delete from a where id=@id
      

  7.   

               delete * from A where c =(select D from B)
      

  8.   

    delete from A where C=(select D from B)