sql 语句加判断规则
2014-10-17 10:47
246 查看
假设现在 传进来2个参数 IsPut ,IsPlus 值都为 1,0
语句大概如下:
select * from table t where ( (IsPut =0 and IsPlus=0 ) or (IsPut =1 and IsPlus=1 AND t.FModifyNO IS NOT NULL) or (IsPut =1 and IsPlus=0 AND t.FModifyNO IS NOT NULL and t.FModifyNO not like 'CG%' ) or (IsPut =0 and IsPlus=1 and t.FModifyNO like 'CG%'))
如果 IsPut =0,IsPlus=0 就会进入执行(IsPut =0 and IsPlus=0 )
如果 IsPut =1,IsPlus=1 就会进入执行(IsPut =1 and IsPlus=1 AND t.FModifyNO IS NOT NULL)
如果 IsPut =1,IsPlus=0 就会进入执行(IsPut =1 and IsPlus=0 AND t.FModifyNO IS NOT NULL and t.FModifyNO not like 'CG%' )
如果 IsPut =0,IsPlus=1 就会进入执行(IsPut =0 and IsPlus=1 and t.FModifyNO like 'CG%')
这样就可以实现判断执行
语句大概如下:
select * from table t where ( (IsPut =0 and IsPlus=0 ) or (IsPut =1 and IsPlus=1 AND t.FModifyNO IS NOT NULL) or (IsPut =1 and IsPlus=0 AND t.FModifyNO IS NOT NULL and t.FModifyNO not like 'CG%' ) or (IsPut =0 and IsPlus=1 and t.FModifyNO like 'CG%'))
如果 IsPut =0,IsPlus=0 就会进入执行(IsPut =0 and IsPlus=0 )
如果 IsPut =1,IsPlus=1 就会进入执行(IsPut =1 and IsPlus=1 AND t.FModifyNO IS NOT NULL)
如果 IsPut =1,IsPlus=0 就会进入执行(IsPut =1 and IsPlus=0 AND t.FModifyNO IS NOT NULL and t.FModifyNO not like 'CG%' )
如果 IsPut =0,IsPlus=1 就会进入执行(IsPut =0 and IsPlus=1 and t.FModifyNO like 'CG%')
这样就可以实现判断执行
相关文章推荐
- SQL条件判断语句
- 一条sql语句判断数据是否存在
- SQL语句判断表 数据库 数据是否存在
- Oracle sql语句优化53个规则详解(三)(www.jiedichina.com)
- 在ASP中判断SQL语句是否执行成功
- 生成字符SQL语句基本规则
- Oracle sql语句优化53个规则详解(一)(www.jiedichina.com)
- SQL语句判断某字段是以字母开头而不是汉字开头
- SQL语句判断某个表是否存在某个字段
- 判断数据库死锁的Sql语句
- 在ASP中判断SQL语句是否执行成功
- 在ASP中判断SQL语句是否执行成功
- Oracle sql语句优化53个规则详解(二)(www.jiedichina.com)
- javascript实例--循环判断查询表单,构建SQL语句
- SQL语句判断某表是否存在
- 如何判断数据库中1个表已经存在,这样不会重复创建一个新表(用sql语句)
- oracle用什么SQL语句判断表存不存在
- sql语句中字段非空的判断
- 生成字符SQL语句基本规则
- 用SQL语句判断数据库中的记录是否存在