WHERE EXISTS ( SELECT 1
FROM (SELECT TOP 100 ID FROM talbeName ) AS B
WHERE (A.ID=B.ID) )
字符类型的ID要复杂些,如果ID是int类型的就更好办了。
获取a字段跟B表中c字段相等的数据的id:select id from A表 a inner join B表 b on a.a字段=b.c字段
删除剩下的数据:
delete from A表 where id not in(select id from A表 a inner join B表 b on a.a字段=b.c字段)
delete from B表 where id not in(select id from A表 a inner join B表 b on a.a字段=b.c字段)
能看的懂是什么意思吗?
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)