从列表中搜索数据 [英] search data from list

查看:113
本文介绍了从列表中搜索数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我在storeprocedure中写查询



选择名称,来自user_data的emailid

where(name LIKE @name +''%' ')或

(emailid LIKE @emailid)

然后搜索将用于名称文本框。但如果我写查询



选择名称,来自user_data的emailid

where(名称LIKE @name +''%'')或

(emailid LIKE @emailid +''%' ')



然后搜索不适用于任何文本框。

此代码有什么问题,我无法理解。请帮助我。

解决方案

试试这个



 选择名称,emailid 来自 user_data 
其中
(名称 LIKE ' %' + @ name + ' %' @ name null
AND
(emailid LIKE ' %' + @ emailid + ' %' @ emailid null

;



希望有帮助你


if I write query in storeprocedure

select name,emailid from user_data
where (name LIKE @name + ''%'') OR
(emailid LIKE @emailid )
then search will work for name textbox .But if i write query

select name,emailid from user_data
where (name LIKE @name + ''%'') OR
(emailid LIKE @emailid + ''%'' )

then search will not work for any textbox.
what is problem with this code, i can''t understand.please help me.

解决方案

Try this

select name,emailid from user_data
where
(name LIKE '%' + @name + '%' OR  @name is null )
AND
(emailid LIKE '%' + @emailid + '%' OR @emailid is null )

;

Hope it helps you.


这篇关于从列表中搜索数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆