主表:
客户编号 下单号  数量  时间明细
下单号 色号  他们通过下单号关联
要用什么语句才能把某一个客户在主表和明细表中的信息全部删除呢?

解决方案 »

  1.   

    delete from 明细 where 下单号 in (select 下单号 from 主表 where 客户编号 = 指定的客户编号)delete from 主表  where 客户编号 = 指定的客户编号
      

  2.   

    先删除明细表 再删除主表
    delete from 明细 A where exists(select 1 from 主表 B where A.下单号 = B.下单号 and B.客户编号 = 指定的客户编号)delete from 主表  where 客户编号 = 指定的客户编号