日期:2014-05-17 浏览次数:20889 次
create table aaa(ID int,NAME varchar2(10),DEPT varchar2(10)) insert into aaa values(1 ,'A', '01') insert into aaa values(2 ,'B', '01') insert into aaa values(3 ,'C', '03') delete from aaa where dept not in (select dept from aaa where name = 'A') select * from aaa /* ID NAME DEPT ---------- ---------- ---------- 1 A 01 2 B 01 2 rows selected. */
------解决方案--------------------
delete from AAA where DEPT <> '01'; --这个01 你可以通过查询得出,但是根据你的描述写死也是可以的。 --不写死 delete from AAA where DEPT <>(select DEPT from dept where NAME = 'A');