id是唯一的吧select * from t t1 where not exists (select 1 from t t2 where name='张三' and dept ='A' and t1.id=t2.id)

解决方案 »

  1.   

    select id,name,dept from tab1
    minus
    select id,name,dept from tab1 t
    where t.dept='A' and t.name='张三'
      

  2.   

    select id, name, dept
      from tab
     where tab.id not in 
     (select id from tab t where t.name = 'A' and t.dept = '張三')
      

  3.   

    select id, name, dept
      from tab
     where  t.name||t.dep !='張三A'
      

  4.   


    --构造测试数据
    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难道不应该这么简单?
      

  5.   

    如果数据量小的话,是可以考虑用下minus