如何在表中的特定列中搜索名称 [英] How to search name in a particular column in table

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

问题描述

其实我在我的表格中使用搜索选项。在学生名称我正在搜索学生表中的记录,例如你可以在下面看到。



/ /学生表

Actually i am using search option in my form.in that by student name i am searching the records from student table for example u can see below.

//student table

student_id  | Name | Class | Created_on
1001        |pavan | second |1/2/2013
1002        |pavani| first  |4/2/2013
1003        |siddu |third   |4/2/2013
1004        |suresh|third   |2/4/2013







现在我想要什么当我在我的搜索文本框中输入pav时,我想从上表中获得前两条记录,如下所示






now what i want is when i enter "pav" in my search-text-box i want to get first two records from the above table like below

student_id  | Name | Class | Created_on
1001        |pavan | second |1/2/2013
1002        |pavani| first  |4/2/2013

推荐答案

从学生中选择*其中名称如''%pav%''
select * from student where Name like ''%pav%''


假设您将名称字段的变量作为Sname而将student_id字段作为Sid接受

string Sname =pav;

string Sid = 01;



sql =select * from student_details where name like''%+ Sname.toString()+%''或student_id like'' %+ Sid.toString()+%'';
suppose if you are taking variable for name field as Sname and for student_id field as Sid then
string Sname="pav";
string Sid="01";

sql="select * from student_details where name like ''%" + Sname.toString() + "%'' or student_id like ''%" + Sid.toString() + "%''";


Dude这是唯一的前端查询,只有在你想要显示时才需要在前端编写查询结果。你想在ASP.net中编写查询,那就是查询。
Dude this is the only query for front end, you have to write query in front end only if u want to display result. You want to write query in ASP.net then that''s the query.


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

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