Skip to main content
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
12 respostas
  1. 5 de nov. de 2024, 07:04

    Hi,

    Find the solution below :

    String searchTerm = '%'+searchKeyword+'%';

    String sql = 'Select Name From Account WHERE Name LIKE : searchTerm';

    Mark this helpful if it solves your query!

0/9000