我有以下疑问:
use VIM_VCDB;
select VPX_ENTITY.NAME as "VM Name", VPX_VM.FILE_NAME as "File Name / Path"
From VPX_VM inner join VPX_Entity
on vpx_vm.ID = vpx_entity.ID
order by VPX_entity.name我想使用此记录同时从两个表中删除返回的数据集。这个是可能的吗?
发布于 2015-08-16 18:52:46
从VPX_VM中删除vpx_vm.ID = vpx_entity.ID的VPX_Entity ...
发布于 2015-08-16 20:59:11
delete语句仅从一个表中删除行。但是,您可以将它们包装在一个事务中,以便它们同时“生效”:
begin transaction twodeletes;
select vpx_vm.ID
into #deleteids
From VPX_VM inner join
VPX_Entity
on vpx_vm.ID = vpx_entity.ID;
delete from VPX_VM where id in (select id from #deleteids);
delete from VPX_Entity where id in (select id from #deleteids);
commit transaction twodeletes;发布于 2015-08-16 21:07:33
无法同时删除。尽管您可以使用以下变通方法:
更新标志set del_ VPX_VM =‘Y’where exists (select 1 VPX_Entity vpx_vm.ID = vpx_entity.ID );
更新标志set del_ VPX_ENTITY =‘Y’where exists (select 1 VPX_VM vpx_vm.ID = vpx_entity.ID );
Delete from where del_ del_flag='Y';
delete from VPX_VM where ID in (select Tmp1 in vpx_vm_ID );
delete from VPX_Entity where ID in (select vpx_entity_id in tmp1);
https://stackoverflow.com/questions/32034158
复制相似问题