sql中删除多张表的数据

insert a.id into #kkk select a.id from a,b where a.id=b.id
delete from a where a.id in(select id from #kkk)
delete from b where b.id in(select id from #kkk)

-------------------------
第一句得到两个表里的相同记录并插入临时表
第二句把A表里的记录删除,条件是#kkk表里的ID
第三句把B表里的记录删除,条件是#kkk表里的ID

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章