delete from tbm_psncalendar 
where tbm_psncalendar.pk_corp = '1001' 
and tbm_psncalendar.pk_psndoc in ( '0001AA1000000000032T' , '0001AA1000000000032W' , 
'0001AA1000000000032Z' , '0001AA10000000000332' ) ;

解决方案 »

  1.   

    delete tbm_psncalendar a from  
    where tbm_psncalendar.pk_corp = '1001' 
    and exists (select 1 from bd_psndoc b where a.pk_psndoc = b.pk_psndoc 
    and b.pk_deptdoc in ( '0001AA1000000000032T' , '0001AA1000000000032W' , 
    '0001AA1000000000032Z' , '0001AA10000000000332' ) );
      

  2.   

    xzou(亡狼补齿) :
        你好!delete tbm_psncalendar a from  
    where tbm_psncalendar.pk_corp = '1001' 
    and exists (select 1 from bd_psndoc b where a.pk_psndoc = b.pk_psndoc 
    and b.pk_deptdoc in ( '0001AA1000000000032T' , '0001AA1000000000032W' , 
    '0001AA1000000000032Z' , '0001AA10000000000332' ) );
    这样写时当exists (select 1 from bd_psndoc b where a.pk_psndoc = b.pk_psndoc 
    and b.pk_deptdoc in ( '0001AA1000000000032T' , '0001AA1000000000032W' , 
    '0001AA1000000000032Z' , '0001AA10000000000332' ) );成立时不是把pk_corp为1001的所有数据都删除了吗?