i need some help here.. am trying to implement a search result
conditions
1# it should fetch records that equals what keyword user enter on textbox(@SEARCH)
2# Along with the first condition It also fetch the matched records which is entered on textbox(@SEARCH)
3# What keyword searched that should show 1st and other matches will show after that( what i means priority queue)
4# It should check @loc paramater and fetch to that keyword.
SQL
@SEARCH NVARCHAR(100) = NULL,
@loc NVARCHAR(100) = NULL
as
select *
from tblBusinessCategory as b
inner join tblUser as u on b.BusinessID=u.BusinessCategoryId
inner join tblAddress as a on u.AddressId=a.AddressID
where b.BusinessName = @SEARCH and
a.City = @loc
OR a.State = @loc
and b.BusinessName LIKE '%' + @SEARCH + '%'
Raja TRank #685 · 3.5K reputationPosted Aug 20, 2015, 1:08 AM EDT
Ruga Lincy35 reputationPosted Aug 20, 2015, 1:19 AM EDT
Raja TRank #685 · 3.5K reputationPosted Aug 20, 2015, 1:27 AM EDT
Ruga Lincy35 reputationPosted Aug 20, 2015, 1:32 AM EDT
Raja TRank #685 · 3.5K reputationPosted Aug 20, 2015, 1:46 AM EDT
Raja TRank #685 · 3.5K reputationPosted Aug 20, 2015, 2:11 AM EDT
Upendra Pratap ShahiRank #329 · 7.5K reputationPosted Aug 20, 2015, 2:32 AM EDT
Raja TRank #685 · 3.5K reputationPosted Aug 20, 2015, 3:00 AM EDT
Upendra Pratap ShahiRank #329 · 7.5K reputationPosted Aug 20, 2015, 2:00 AM EDT
@SEARCH NVARCHAR(100) = NULL,
@loc NVARCHAR(100) = NULL
as
select *
from tblBusinessCategory as b
inner join tblUser as u on b.BusinessID=u.BusinessCategoryId
inner join tblAddress as a on u.AddressId=a.AddressID where
b.BusinessName LIKE '%' + @SEARCH + '%' or
a.City LIKE '%' + @loc + '%' or
a.State LIKE '%' + @loc + '%'
order by b.BusinessName asc
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questionsTop experts