You need to sign in to do that
Don't have an account?
Vivekh88
LIKE Operator in SOQL
Hi,
I have a soql query where i am using LIKE operator.
String sql = 'Select Name From Account WHERE Name LIKE \'%' + searchKeyword + '%\'';
Here 'searchKeyword' variable holds values like 'Test 1, Test 2, Test 3, Test 4'.
When i search a Name in my VF page which is a Textbox, like this 'Test 1, Test 4' its not returning the searchKeyword values. Because LIKE operator searches values only in Orderwise. It cant search middle values.
Is there any possible solution where it searches all values that are contained in the textbox?
Thanks
Vivek
I have a soql query where i am using LIKE operator.
String sql = 'Select Name From Account WHERE Name LIKE \'%' + searchKeyword + '%\'';
Here 'searchKeyword' variable holds values like 'Test 1, Test 2, Test 3, Test 4'.
When i search a Name in my VF page which is a Textbox, like this 'Test 1, Test 4' its not returning the searchKeyword values. Because LIKE operator searches values only in Orderwise. It cant search middle values.
Is there any possible solution where it searches all values that are contained in the textbox?
Thanks
Vivek
For example, the following query matches Appleton, Apple, and Appl, but not Bappl:
NOTE:- in like statement you can pass only single word or matching char not multiple string with ,
Thanks for the reply. So you are telling we can search the values like 'Test 1, Test 2', Test 3. We cant search 'Test 1, Test 3' Which is not in order?
Thanks
Vivek
Then your query will be like below
Select Name From Account WHERE Name LIKE '%Test%'
and above query will return all record which contain Test.
i am not passing 'Test' keyword in my query. I am using a apex variable. So that it accepts all values. So in that case i cant give 'Test' inside my query right?
Thanks
Vivek
String j= '%'+a+'%';
List<Account> accList = [select id,Name,description from Account where name like :j];
string searchquery='select name,id from account where name like \'%'+searchstring+'%\' Limit 20';