Ruga Lincy

Ruga Lincy

  • NA
  • 42
  • 7k

Search based on Priority queue

Aug 20 2015 4:56 AM

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.

@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 + '%'

Answers (9)