一数据表,包含名为ID的字段,求一SQL语句,查出的结果需要符合如下要求:
1.id >10 and id < 20
2.id <> 15
3.id > 100
4.id = 4
重要的是上面的条件不能进行拆分,比如不能将1和2拆分为:(id>10 and id < 15) or (id > 15 and id<20)
在下在这里先谢过大家了!
1.id >10 and id < 20
2.id <> 15
3.id > 100
4.id = 4
重要的是上面的条件不能进行拆分,比如不能将1和2拆分为:(id>10 and id < 15) or (id > 15 and id<20)
在下在这里先谢过大家了!
解决方案 »
- dbms_sqltune问题再问
- 如何在视图中查询TEMP和UNDO两个表空间的使用情况
- oracle存储过程问题请教
- 请教一下,这是数据库的问题还是连接池的问题
- 求助:物化视图问题
- 一个sql语句的问题
- 我是DBA身份,为什么在DBA Studio中没法用sysdba模式登陆?却只能用nomal来用?
- 如何取出返回记录集的前十条记录?
- 是谁更改了我地数据库表记录?
- 打开Oracle Enterprise Manager工具登陆的时候,如果选择登陆到Oracle Managerment Server会出错,提示:VTK-1004:读取客户机注册表发生
- oracle数据库的登录
- oracle中与||功能相同的是哪个?十个选择题,但记不清选项,有谁知道答案呢?谢谢大家!!!
实际上我是要做一个权限设置问题,
举例说明:
表内数据有:
id
3
4
5
11
12
15
16
101
102
用户设置了四个权限,每个权限程序将自动产生如下条件:
1.id >10 and id < 20(结果集中包含id是11~19的数据)
2.not id = 15(结果集中不包含id是15的数据)
3.id > 100(结果集中包含id大于100的数据)
4.id = 4(结果集中包含id是4的数据)希望结果如下:
id
4
11
12
16
101
102
重要的是上面的条件不能进行拆分,比如不能将1和2拆分为:(id>10 and id < 15) or (id > 15 and id<20)
在下在这里先谢过大家了!
union
select * from t where id <>15
union
select * from t where id > 100
union
select * from t where id = 4 哈哈 不知道啥结果!
(
select * from t where id >10 and id < 20
union
select * from t where id > 100
union
select * from t where id = 4
) T1
where T1.id <>15
应该可以得到结果 不过很诡异啊!
没有实际意义啊?
union
select * from t where id > 100
union
select * from t where id = 4不知道楼主为什么这样来设计权限分配算法,有点怪怪的!
是不能把条件进拆分而后再进行重新组合------------
已经得到结果:
id<>15 and (id=4 or (id>10 and id<20) or (id>100))
union all
select * from t where id <>15
union all
select * from t where id > 100
union all
select * from t where id = 4