Aggregate LIKE operator search for words even if not sequencial


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.



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.



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 (

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
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 ....

Hi Fábio.
Did you solve this?, I have the same problem and I have tried different ways to solve it but i have not been able to.


Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.