Hi,

I have applied a filter using like operator ,if i search for a value 1_test

i returns  the records 1_test,1mtest,1ntest,1jtest.But i want only 1_test to be returned.


Thanks,

Ronan T

Hi Rohan,


how are you using like operator-

find below example-

WHERE CustomerName LIKE 'a%'Finds any values that start with "a"
WHERE CustomerName LIKE '%a'Finds any values that end with "a"
WHERE CustomerName LIKE '%or%'Finds any values that have "or" in any position
WHERE CustomerName LIKE '_r%'Finds any values that have "r" in the second position
WHERE CustomerName LIKE 'a__%'Finds any values that start with "a" and are at least 3 characters in length
WHERE ContactName LIKE 'a%o'Finds any values that start with "a" and ends with "o"

WHERE ContactName LIKE 'abc'
same value return only


or you can useentity.column like 'value' or entity.column lik='value


Thanks

Rahul Sahu


Rahul Sahu wrote:

Hi Rohan,


how are you using like operator-

find below example-

WHERE CustomerName LIKE 'a%'Finds any values that start with "a"
WHERE CustomerName LIKE '%a'Finds any values that end with "a"
WHERE CustomerName LIKE '%or%'Finds any values that have "or" in any position
WHERE CustomerName LIKE '_r%'Finds any values that have "r" in the second position
WHERE CustomerName LIKE 'a__%'Finds any values that start with "a" and are at least 3 characters in length
WHERE ContactName LIKE 'a%o'Finds any values that start with "a" and ends with "o"

WHERE ContactName LIKE 'abc'
same value return only


or you can useentity.column like 'value' or entity.column lik='value


Thanks

Rahul Sahu


Hi Rahul,

I am using below code

SyntaxEditor Code Snippet

Employee.name like "%"+name+"%" 

thanks,

Ronan

Hi Ronan,

If you are using an SQL database, enclosing the underscore in [ ] should do the trick.

If not, I don't know. There is the ESCAPE clause that works on any DBMS, but you can't use it in an Aggregate.

Cheers.

Ex:

WHERE username LIKE '%[_]d';          
WHERE username LIKE '%$_d' ESCAPE '$';
WHERE username LIKE '%^_d' ESCAPE '^';

But if you are using a variable in the filter, you would have to replace the _ with [_] in the text to it to work.

Cheers.

In addition to Rahul: 

You can escape the _ by using '[_]'. So in that case you use LIKE "1[_]test%"