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