Skip to main content
Vivekh Raj (Infosys) が「#Apex」で質問
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 件の回答
  1. 2024年11月5日 7: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