I’m very confused with the soql Like operator.
If I have a record with a text field that may contain: "Orders to be shipped, pack blue labels/zip/ authorization slip needed.”
And a user enters “blue authorization” into our search,It will not bring in that order at all.
Here is the query:
string search = 'SELECT id, Name, order_information__c from order WHERE (Name like \'%' + searchstring + '%\' OR order_information__c like \'%' + searchstring + '%\') Limit 50';
Orders = Database.query(search);
Basically in our vf page we have a search that a user enters in whatever and it brings in orders that match in either name or order_information__c
If the user types in "blue label", it will bring in records but not "blue authorization".
How can we search the whole string if the search term may contain any of the words in the string?
Salesforce’s standard search is able to do this, that if a user just types in “blue authorization” it brings in any record with that in their order_information
Best Answer
The answer from battery.cord needs some improvements, but gets you in the right direction.
I would suggest something more like:
The important points here: