oracle的where条件里有不包括的条件吗?解决思路
oracle的where条件里有不包括的条件吗?
比如
select * from table t where !(t.name="张三" and t.dept='业务部')
这里面的!能用吗?就是查询不包括名字是张三,部门在业务部的所有人
------解决方案--------------------
------解决方案--------------------
1 <> :
2 not in:
3 not exists:
------解决方案--------------------
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楼都列出了
比如
select * from table t where !(t.name="张三" and t.dept='业务部')
这里面的!能用吗?就是查询不包括名字是张三,部门在业务部的所有人
------解决方案--------------------
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楼都列出了