I'm having a table
with some columns e.g.
. Looks like this:
- Id (uniqueidentifier)
- DocumentTitle (varchar(200))
in my application you enter a string you search for like "invoice 4711". Now my application shall search for all documents where both of these words are in the title.
So documents with title
won't be found.
Documents with title
shall be found.
Since i write this in a procedure i can't set a fix parameter-count for searchstrings. I'm getting one parameter e.g.
and my split-method returns a table with all items like (and yes, with the %-signs)
Sooo when I try now to get all Documents where both of those values match I get a wrong result (but, yes it makes always sense :D )
: the fn_split- function takes the searchstring as first parameter and the second parameter is the sliced sign
WHERE 1 = (
when document.documenttitle like items then 1 else 0 end
from fn_split('invoice 4711', ' ')
where document.documenttitle like items
inner join fn_split('invoice 4711', ' ')
on document.DocumentTitle like items
both of these queries returns the result where any of those words are contained - not both.
Any idea what the issue is here? or how the query works right?