delete from a where exists (select 1 from a as tb where tb.title=a.title and tb.Name=a.Name and a.keyword=tb.keyword and tb.id1<>a.id1)delete from b where id2 not in (select id1 from a)
三个字段完全相同的是全部删除还是保留一个? --A表全部删除相同的delete from A t where (select count(*) from A where name = t.name and title = t.title and keyword = t.keyword) > 1--A表保留一条重复记录delete t from A t where exists (select 1 from A where name = t.name and title = t.title and keyword = t.keyword and id > t.id) --删除A表记录后删除B表相关记录delete b from B b where not exists (select 1 from A where id1 = b.id2)
delete from a where id1 not in (select min(id1) from a as tb where tb.title=a.title and tb.Name=a.Name and a.keyword<>'') delete from b where id2 not in (select id1 from a)
delete from a
where exists (select 1 from a as tb where tb.title=a.title
and tb.Name=a.Name and a.keyword=tb.keyword
and tb.id1<>a.id1)delete from b
where id2 not in (select id1 from a)
--A表全部删除相同的delete from A t where (select count(*) from A where name = t.name and title = t.title and keyword = t.keyword) > 1--A表保留一条重复记录delete t
from A t
where exists (select 1 from A where name = t.name and title = t.title and keyword = t.keyword and id > t.id)
--删除A表记录后删除B表相关记录delete b
from B b
where not exists (select 1 from A where id1 = b.id2)
where id1 not in
(select min(id1) from a as tb where tb.title=a.title
and tb.Name=a.Name and a.keyword<>'')
delete from b
where id2 not in (select id1 from a)