select id,name,dept from tab1 minus select id,name,dept from tab1 t where t.dept='A' and t.name='张三'
select id, name, dept from tab where tab.id not in (select id from tab t where t.name = 'A' and t.dept = '張三')
select id, name, dept from tab where t.name||t.dep !='張三A'
--构造测试数据 with test as ( select 1 as id,'张三' as name,'A' as dept from dual union all select 2 as id,'张三' as name,'B' as dept from dual union all select 3 as id,'李四' as name,'A' as dept from dual union all select 4 as id,'李四' as name,'B' as dept from dual ) --你需要的查询语句: select * from test where name!='张三' or dept!='A';--result: ID NAME DEPT ---------- ---- ---- 2 张三 B 3 李四 A 4 李四 B难道不应该这么简单?
minus
select id,name,dept from tab1 t
where t.dept='A' and t.name='张三'
from tab
where tab.id not in
(select id from tab t where t.name = 'A' and t.dept = '張三')
from tab
where t.name||t.dep !='張三A'
--构造测试数据
with test as (
select 1 as id,'张三' as name,'A' as dept from dual
union all
select 2 as id,'张三' as name,'B' as dept from dual
union all
select 3 as id,'李四' as name,'A' as dept from dual
union all
select 4 as id,'李四' as name,'B' as dept from dual
)
--你需要的查询语句:
select * from test where name!='张三' or dept!='A';--result:
ID NAME DEPT
---------- ---- ----
2 张三 B
3 李四 A
4 李四 B难道不应该这么简单?