oracle 查询语句根据参数值来动态生成条件

来源:互联网 发布:海上知生机搜救队视频 编辑:程序博客网 时间:2024/05/16 07:17

select *

from  student

where age=&age

and sex=1

and name=&name

and  .....

 

这是多个条件的语句. 可用户要选择不同的条件来看同样的信息.  要看 年龄大于20岁的, 性别是女的, 姓名是什么来的.  这些要求.

而且这些条件不固定的.

 

select  *

from student

where 1=1

and (&age is nul or age=&age)

and (&sex='All' or sex=&sex)

原创粉丝点击