SQL查询与多个字段的搜索 [英] Sql Query for Search with mutiple Fields

查看:127
本文介绍了SQL查询与多个字段的搜索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

朋友,
我正在通过以下字段搜索数据

1)公司名称

2)员工姓名

3)状态

4)城市

5)专长

6)语言


我为上面的搜索编写了单独的存储过程.例如,下面的Sp是上面搜索的字段之一

我的Sp是:

hi friends,
i am searching the data by following fields

1) Company Name

2) Employee Name

3) State

4) City

5) Specialty

6) Language


I written individual stored procedures for the above search..For Example Below Sp is one of the above fields search

My Sp Is:

@EmpName varchar(50)
as
begin
select distinct E.UserId,E.EmployeeId,E.Name,P.Picture,C.Id,C.AddressId,C.CompanyName,A.Line1,A.Line2,A.City,A.State,
PL.ProviderId,L.CodeType from
 Employee E,EmployeeCompany EC,Company C,Provider P,Address A,ProviderLookup PL,CompanyProvider  CP,
 Lookup L
 where E.Name=@EmpName  and C.AddressId=A.Id and C.CreatedUserId=E.CreatedUserId
and PL.ProviderId=E.EmployeeId and P.UserId=E.EmployeeId and Cp.CompanyId=C.Id and
PL.ProviderLookupId=L.Id and EC.CompanyId=C.Id and EC.ProviderId=E.EmployeeId and
 E.IsEmployeeProvider='true' and L.CodeType!='Language'

end




有什么办法可以将这些全部写在单个存储过程中吗?

请帮帮我..

在此先感谢




Is there any way to write these all are in a single stored procedure

Please help me..

Thanks in advance

推荐答案

您是否尝试过全文搜索:
http://blog.sqlauthority.com/2008 /09/05/sql-server-creating-full-text-catalog-and-index/ [
have you tried full text search:
http://blog.sqlauthority.com/2008/09/05/sql-server-creating-full-text-catalog-and-index/[^]


这篇关于SQL查询与多个字段的搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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