作者fantasyj (如梦似幻)
看板Database
标题Re: [SQL ] 如何同时删除两个不同资料表里的资料?
时间Sun Feb 20 15:49:40 2011
※ 引述《Snow2112 (Snow)》之铭言:
: 假设我有A和B两个资料表,A的主键num是B资料表的外来键,现在我要删除A资料表
: 里num为1的资料,但同时也要删除B资料表里外来键num为1的资料,语法该怎麽写呢?
就两段delete sql而已..
delete from table_b b where b.num = 1;
delete from table_a a where a.num = 1;
commit;
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 59.117.124.40
1F:推 CavalryTseng:我也只想到这个 @@ 02/20 22:26
2F:→ tedcat:foreign key trigger? 02/21 23:03