日期:2014-05-18 浏览次数:20472 次
Delete from A where id not in (select ID from (select productid,min(id) as ID from A group by productid) T ) go Delete from b where id not in (select iD from A)
------解决方案--------------------
create table # (id varchar(20),name varchar(20),number varchar(20),productid varchar(20) ) insert into # values('342','162029302','2.4*1217','443') insert into # values('321','163229302','4.9*1219','443') insert into # values('765',' price th
------解决方案--------------------
delete aa from a aa where exists(select 1 from a where productid=aa.productid and id>aa.id) delete b where id not in(select id from a)
------解决方案--------------------
ta上创建触发器
CREATE TRIGGER t ON ta FOR DELETE AS DELETE FROM tb b INNER JON DELETED a ON a.id=b.id
------解决方案--------------------
---触发器
create trigger del_b on 表1 for delete as delete from # where id in (select id from deleted)
------解决方案--------------------
delete from b
where b.id in ( select max(id) from a group by productid having count(1) > 1 )
delete from a
where a.id in ( select max(id) from a group by productid having count(1) > 1 )