2个表
tableA
tableb
其中b的id 与 A的id 值相同。
根据 tableA中的 type 分组、统计记录合。找到大于100条记录的type删除每个大于100条记录的 type  100条以后的所有记录。 同时删除,tableB中相对应的记录

解决方案 »

  1.   

    DELETE bill,payment FROM bill,payment WHERE bill.pay_id = payment.pay_id AND payment.charge=(select charge from (select charge,count(*) c from payment group by charge having c>2) n) 试试
      

  2.   

    这里 A 代表 tableA,B代表tableB。delete from tableA,tableB where B.id = A.id and A.id in ( select id from A where type in (select type, count(*) as counttype from A where 1  group by tableA.type having counttype > 100) )以上应该已经实现了。
      

  3.   

    哎,MySQL5的新特性不怎么熟了。楼上的两层子查询,以前可不敢想的啊!叹一个……