sql的delete怎样同时删除多个表中的记录?
deletefromtable1wherefielda=N deletefromtable2wherefieldb=Nandc=N怎样把这两个表用一个delet...
delete from table1 where field a=N delete from table2 where field b=N and c=N 怎样把这两个表用一个delete删掉呢? 这样写肯定是错的delete from table1 ,table2 where a=N and b=N and c=N 那该如 何写sql语句才能按照where条件一次性的删除两个表中的记录呢?
展开
1个回答
展开全部
针对第一个表写个删除触发器,使得删除第一个表的同时删除第二个表的数据。
create trigger del_tab on table1
for delete
as
if (select a from deleted)='N'
begin
delete from table2 where field b=N and c=N
end;
create trigger del_tab on table1
for delete
as
if (select a from deleted)='N'
begin
delete from table2 where field b=N and c=N
end;
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询