Aggregate LIKE operator search for words even if not sequencial

Hey,

Title is a mess but I couldn't describe it well in a few words.

Here's what I have right now:

Input where you write whatever you want to search.

Let's say you type "GDBP Online" and hit search, in the list I have two strings,

1-"GDBP Online Test", which is returned on the search;

2-"GDBP Test Online", which is not returned.


In my aggregate I have a normal like operator 

SyntaxEditor Code Snippet

Content.Title like "%" + Session.Content_SearchKeyword + "%"


Although the second string doesn't have both words sequential, I still need to return it in the search because it has the two words typed in.


Is there a way I could do this?


I can't have heavy logic here, we are talking about hundreds of records. Mobile app btw.

Hi,

As long as the words enter should be in the same sequence as in the table, why not replace all spaces in the filter with and %.

That should work.

Regards,

Daniel 

Hi Fábio, it is possible to get what you want, but there is a catch.

The catch is, you will have to do some work before (create a function to create the filter statement)

We will assume that the DB is Microsoft SQL Server, I think that it is.

The solution that I could get is to use the charindex function (https://docs.microsoft.com/en-us/sql/t-sql/functions/charindex-transact-sql?view=sql-server-ver15)

This is an example that you can try it out for fun

CHARINDEX(find-what, find-where, start-from-character-position)

select Content.Title
from Content
where (CHARINDEX('GDBP',Content.Title ,0)>0
and
CHARINDEX('Online',Content.Title ,0)>0
)

This will select all titles that have both variables on the title, in any order they night apear. 

Hope this will help you

Good coding ....