sql语句如下:
sql = "select * from info where classid=19 and nclassid=31 and title like'%" + title + "%'and leixing like'%" + leixing + "%'and synopsis='" + synopsis + "'order by id desc";
现在我想对title(名称) leixing(类型) synopsis(索引号)任意一项进行查询,上面代码怎么修改?
效果如http://zwgk.shaoguan.gov.cn/website/govPublic/govPublicSiteAction!deptgovp_list.action?deptId=682&pagesize=15&siteOrgCode=440200
sql = "select * from info where classid=19 and nclassid=31 and title like'%" + title + "%'and leixing like'%" + leixing + "%'and synopsis='" + synopsis + "'order by id desc";
现在我想对title(名称) leixing(类型) synopsis(索引号)任意一项进行查询,上面代码怎么修改?
效果如http://zwgk.shaoguan.gov.cn/website/govPublic/govPublicSiteAction!deptgovp_list.action?deptId=682&pagesize=15&siteOrgCode=440200
sql = "select * from info where classid=19 and nclassid=31 and (title like'%" + title + "%' or leixing like'%" + leixing + "%'or synopsis='" + synopsis + "') order by id desc";
and 连接改为or嘛
@ptitle varchar(1000)=null
@pleixing varchar(1000)=null
@psynopsis varchar(1000)=null
as
select * from info where classid=19 and nclassid=31 and
(title=isnull(@ptitle,'') or isnull((@ptitle,'')='') and
(leixing=isnull(@pleixing,'') or isnull(@pleixing,'') ='') and
(synopsis=isnull(@psynopsis,'') or isnull(@psynopsis,'')='')