Like Operator usage in Apex

Example:

String sql = 'Select Name From Account WHERE Name LIKE \'%' + searchKeyword + '%\'';

(or)

List<Contact> listCon = [SELECT Id, FirstName FROM Contact WHERE FirstName LIKE '%test%'];

system.debug('List contacts are ' + listCon);

where searchKeyword is an Apex variable.

Cheers!!!

No comments:

Post a Comment