Interview Questions   Tutorials   Discussions   Programs   

Apex - Difference between SOQL and SOSL?

asked kiran-57 February 1, 2013 03:47 AM  

Difference between SOQL and SOSL?


1 Answers

answered By   0  
SOQL statement evaluate a list of sObject, a single sObject or an integer of count method query.
For Example:
List<Account> lst=[select Id, Name from Account];

You can also create new objects from SOQL queries on existing ones.

SOSL Statements of list of sObject, where each list contains the search results for a particular sObject type. The result lists are always returned in the same order as they were specified in the SOSL query.SOSL queries are only supported in Apex classes and anonymous blocks. You cannot use a SOSL query in a trigger. If a SOSL query does not return any records for a specified sObject type, the search results include an empty list for that sObject.

For Example:
List<List<sObject>> lst = [Find 'map*' IN All FIELDS RETURNING Account(Id, Name), Contact, Opportunity];

Account[] accounts = ((List<Account>)lst[0]);
Contact contacts = ((List<Contact)lst[1]);
   add comment

Your answer

Join with account you already have



Ready to start your tutorial with us? That's great! Send us an email and we will get back to you as soon as possible!