现在有两张表,一张A表,一张B表。
两张表有三个主键名称是一样的,
想把B表中INSERT_TIME字段为NULL的数据,
在A表中删除,该如何在一句SQL中写?

解决方案 »

  1.   

    delete a
    from a
    join b on a.id = b.id and b.INSERT_TIME is null
      

  2.   

    delete a
    from a
    join b on a.id1 = b.id1 and a.id2 = b.id2 and a.id3 = b.id3 and b.INSERT_TIME is null
      

  3.   

    delete A from A inner join B on A.id=B.id and B.INSERT_TIME=null
      

  4.   

    delete from a ,b where a.主键=b.主键 and b.INSERT_TIME is null
      

  5.   

    delete a from a join b on a.主键=b.主键 and b.INSERT_TIME is null
      

  6.   

    delete a from a 
    join b on a.id1 = b.id1 and a.id2 = b.id2 and a.id3 = b.id3 and b.INSERT_TIME is null
      

  7.   

    delete a
    from a
    where exists (select 1 from b
        where b.pk1=a.pk1
        and b.pk2=a.pk2
        and b.pk3=a.pk3
        and b.INSERT_TIME is null)