关于空参数查询的问题

rextan 2010-08-05 02:49:33
mysql 参数为空是不查询 参数非空时查询,这个查询语句怎么写?
select * from a where a.b=b and a.c=c
现在只要有参数为null就查询不出来。
...全文
78 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
rextan 2010-08-05
  • 打赏
  • 举报
回复
HQL语句
rextan 2010-08-05
  • 打赏
  • 举报
回复
语句是这样的.
select new goods(g.goodsid,g.wprice,g.spicpath,g.brand,g.sort,g.style) from goods g where g.brand.brandid = :brandid and g.style.styleid = :styleid

is not null 出错的.
ACMAIN_CHM 2010-08-05
  • 打赏
  • 举报
回复
你的完整代码是什么?
select * from a where a.b=b and a.c=c

这个语句的参数是怎么来的?通过你的ASP程序生成的查询SQL语句还是存储过程中?

问题说明越详细,回答也会越准确!参见如何提问。(提问的智慧
vipper23 2010-08-05
  • 打赏
  • 举报
回复
select * from a where a.b is not null and a.c is not null;
rextan 2010-08-05
  • 打赏
  • 举报
回复
查询where的参数可能为空,当为空的时候省略空的参数.查出符合不是空参数的记录.
ACMAIN_CHM 2010-08-05
  • 打赏
  • 举报
回复
你的参数是什么加的?
rucypli 2010-08-05
  • 打赏
  • 举报
回复
if b='' then
select * from tb;
else
select * from a where a.b=b;
end if;
loveflea 2010-08-05
  • 打赏
  • 举报
回复
select * from a where a.b is null and a.c is null;

56,678

社区成员

发帖
与我相关
我的任务
社区描述
MySQL相关内容讨论专区
社区管理员
  • MySQL
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧