关于删除的sql问题

mosquitoyam 2003-10-19 08:39:01
有A,B两个表,都有NO这一属性,NO中都有S1这个值
请问如何同时删除A,B二表中NO='S1’的元组
是不是用INNER JOIN?
具体请那位说一下,谢谢!
...全文
29 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
wzh1215 2003-10-19
  • 打赏
  • 举报
回复
一次性删除不会!
welyngj 2003-10-19
  • 打赏
  • 举报
回复
create table a
(no int,
h1 int)
create table b
(no int,
h2 int)


insert into a values(1,2)
insert into b values(1,3)
insert into b values(2,3)
insert into a values(3,3)

create trigger tri_del_a
on a
for delete
as
delete b from deleted where deleted.no='1' and deleted.no=b.no
-------------
delete a where no=1
friendliu 2003-10-19
  • 打赏
  • 举报
回复
delete A where no='s1'
delete B where no='s1'
go
lijinqiang 2003-10-19
  • 打赏
  • 举报
回复
delete A where no='s1'
delete B where no='s1'
welyngj 2003-10-19
  • 打赏
  • 举报
回复
是不是用INNER JOIN?
不是。

34,575

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧