SOSL stands for Salesforce Object Search Language.
While SOQL can only search one object at a time, SOSL has the ability to search across multiple objects.
SOSL evaluates to a list.
Here is an example of SOSL in action:
// Program To Search the given string in all Object // List to hold the returned results of sObject generic type List<list<SObject>> invoiceSearchList = new List<List<SObject>>(); // SOSL query which will search for 'ABC' string in Customer Name field of Invoice Object invoiceSearchList = [FIND 'ABC*' IN ALL FIELDS RETURNING APEX_Invoice_c (Id,APEX_Customer_r.Name)];
If you wanted to search for ‘ABC’ across the Account object as well as the Invoice object, you’d do it like so:
invoiceAndSearchList = [FIND 'ABC*' IN ALL FIELDS RETURNING APEX_Invoice__c (Id,APEX_Customer__r.Name), Account];