If you want to use LIKE Keyword in SOQL query as database (SQL) style, it simply don't allow as shown below:

SELECT Id,Title FROM KnowledgeArticleVersion WHERE Language ='en_US' AND PublishStatus ='Online' AND Title LIKE '%'+searchstring+'%'

The above line of code gives you error as 
1. expecting a colon
2. line breaks not allowed in string literals

SOLUTION:

1. For this, you need to put : after Like keyword
2. Always suggested to declare a STRING for Regular Expressions / Wildcard Characters


String newSearchString = '%'+searchstring+'%';

SELECT Id,Title FROM KnowledgeArticleVersion WHERE Language ='en_US' AND PublishStatus ='Online' AND Title LIKE : newSearchText

Post a Comment

If you have any doubts, Please comment below and I will respond to you.

Previous Post Next Post