Activity Forums Salesforce® Discussions what are the diffrent use cases of SOSL and SOQL in salesforce?

  • Deepak

    Member
    January 22, 2020 at 3:35 pm

    Hi Mohit,

    You can use SOQL to fetch records for a single object.

    You can use SOSL to search fields across multiple object.

  • Anjali

    Member
    January 22, 2020 at 5:03 pm

    You can differentiate while considering where to use it:

    Use SOQL when

    1. You know in which objects or fields the data resides.
    2. You want to retrieve data from a single object or from multiple objects that are related to one another.
    3. You want to count the number of records that meet specified criteria.
    4. You want to sort results as part of the query.
    5. You want to retrieve data from number, date, or checkbox fields.

    Use SOSL when

    1. You don't know in which object or field the data resides and you want to find it in the most efficient way possible.
    2. You want to retrieve multiple objects and fields efficiently, and the objects may or may not be related to one another.
    3. You want to retrieve data for a particular division in an organization using the divisions feature, and you want to find it in the most efficient way possible.

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos