select * from table t1 where not exists(select 1 from t t2 where t2.name="张三" and t2.dept='业务部' and t1.name=t2 and t1.dept=t2.dept)
------解决方案-------------------- 1 <> :
select * from table t where t.name <> '张三' and t.dept='业务部';
2 not in:
select * from table t where t.name not in ('张三') and t.dept='业务部';
3 not exists:
select * from table t where t.dept='业务部'
and not exists (select 1 from table tt where tt.id=t.id and tt.name='张三' );
------解决方案-------------------- select * from t_name t where t.name not in ('xxx') and t.dept='xxx';
或者
select * from t_name t where t.name !='xxxx' and t.dept='xxx' ------解决方案-------------------- 3楼都列出了