如果名称和价格为空会检索出所有的数据

  1 select * from TblProduct
2 where (@proName='' or chvProName like '%'+@proName+'%')
3 and (@minPrice='' or mnyProPrice>=@minPrice)
4 and (@maxPrice='' or mnyProPrice<=@maxPrice);
5
6--下面将参数替换成字符串
7 --测试
8 select * from TblProduct
9 where (''='' or chvProName like '%'+''+'%')
10 and (''='' or mnyProPrice>=null)
11 and (''='' or mnyProPrice<=null);
--检索出所有的商品

注:' ' is null  返回的false

--如果更改成下面代码:会报【从数据类型 varchar 转换为 numeric 时出错。】的错
select * from TblProduct
where (' '=' ' or chvProName like '%'+''+'%')
and (' ' is null or mnyProPrice>='')
and (' ' is null or mnyProPrice<='');

如果将mnyProPrice>='' 改为mnyProPrice>=null则不会报错,但因为条件不满足,检索不到任何数据

最新文章

  1. lua命令行编译
  2. 使用NetBeans、Eclipse阅读JDK源码
  3. 实现在Android 进程和线程
  4. Java初学(三)
  5. intellij 2016注册
  6. Navicat 11使用技巧
  7. (整理)C#实现UDP广播
  8. 亚马逊 在线测试题目 amazon (变种的)三叉树的最近公共祖先问题
  9. IOS 调用系统发邮件Api
  10. Vasya and String(尺取法)
  11. Linux下NAT模式和桥接模式的网络配置
  12. idea报错:[2016-08-31 09:20:10,763] Artifact xxx:war exploded: Error during artifact deployment.
  13. centos 7 忘记密码
  14. scala中to和util操作
  15. 纯js倒计时效果(交流加群:452892873)(本群每天都更新学习资料)
  16. mysql优化概述2
  17. CSS&amp;&amp;xpath
  18. 深拷贝(deep clone)与浅拷贝(shallow clone)
  19. IIS自定义404错误不能生效的原因
  20. 前端开发 - HTML - 简介

热门文章

  1. 描述一下C#中索引器的实现过程,是否只能根据数字进行索引?
  2. CKEditor Html Helpers for ASP.NET MVC3 Razor/WebForms Views
  3. JavaScript 模板引擎实现原理解析
  4. 快速入门系列--WebAPI--03框架你值得拥有
  5. Android入门(三)Activity-生命周期与启动模式
  6. Aspect Oriented Programming
  7. 【博客美化】06.添加QQ交谈链接
  8. 深入理解CSS中的空白符和换行
  9. SQL*Loader之CASE1
  10. Unity3D 中的三个Update()方法