Click here to Skip to main content
15,909,193 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

Searching query for sql database table like Facebook


I want to make a query if a user searches for a name like "LOERUM ISPUM" then the exact match comes first and then the least matches comes later

--------------------------------------
ID Name
1 | Loerum Ispum
2 | Loerum Is
3 | Loerum

I want this hierarchy for my search , I have already used LIKE keyword but it does not makes a required sequence please write a query for me , thanks in advance
Posted

1 solution

You are looking for full-text search[^]. Please, follow the link and read all related articles.
 
Share this answer
 
Comments
sajid zafar_Iqbal 27-Nov-13 7:12am    
i have implemented it but it is not showing me the result
DECLARE @SearchWord varchar(500)
SET @SearchWord ='"4522741340 Babar abc "'
SELECT *
FROM ClientDetailDummy
WHERE CONTAINS((ClientDetailDummy.NHSNumber,ClientDetailDummy.Forename,ClientDetailDummy.Surname) , @SearchWord) ;
I have write this query and full text search catalogs on these three colunms , the given string data is exists in database table record but my query is not showing me even a single result.
RedDk 27-Nov-13 12:55pm    
Try adding "%" to the present search string. Multiple characters prefixed or suffixed will cause the current string to return nill.
Maciej Los 27-Nov-13 13:05pm    
I suspect you are trying to search words near to another. Please, see: Search for Words Close to Another Word with NEAR[^]

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900