I am developing a search system…
A user enters the following search: “project managers finance”
We have a table with tags…
tbl_tags with the following items (phrases) in the table:
ID Tag
1 Project Managers
2 Programme Managers
3 Finance
4 Finance Managers
I want to split the search phrase and pull results that have only are exactly matched in the database. E.g. ID’s 1 and 3 (not 2 and 4)
What is the best way to go about this as a SQL query?
My current method is very long winded and involves producing all results for each word in the query e.g. Contains(tag,"project OR manager OR finance"), producing all results for that then comparing each produced tag using instr(query,oRS("Tag")).
I have full text enabled so can use contains if necessary.
I have just found a solution for this problem, using
CHARINDEXto compare theCONTAINSresults to a string.http://msdn.microsoft.com/en-us/library/ms186323.aspx