Activity Forums Salesforce® Discussions What is the difference between SOSL queries and SOQL queries in Salesforce?

  • Subhendu

    Member
    January 12, 2018 at 6:17 am

    Hi Kapil,

    As the name suggests SOQL is Salesforce Object Query language and SOSL is Salesforce Object Search Language.  The first one is used to query on Salesforce objects, it allows you to perform DML operation on the query result. The latter is used to perform the search operation on Salesforce objects, it does not allow you perform DML on its result. SOSL is used when you don’t know which object or field your data resides in.

    Hope this helps.

    Thanks,
    Subhendu

  • Parul

    Member
    September 18, 2018 at 6:35 pm

    Hi

    SOQL:
    1) SOQL (Salesforce Object Query Language ) retrieves the records from the database by using “SELECT” keyword.
    2) By Using SOQL we can know in Which objects or fields the data resides.
    3) We can retrieve data from single object or from multiple objects that are related to each other.
    4) We can Query on only one table.

    SOSL:
    1) SOSL(Salesforce Object Search Language) retrieves the records from the database by using the “FIND” keyword.
    2) By using SOSL, we don’t know in which object or field the data resides.
    3) We can retrieve multiple objects and field values efficiently when the objects may or may not be related to each other.
    4) We can query on multiple tables.

     

    Thanks

  • shariq

    Member
    September 19, 2018 at 9:36 pm

    Hi,

    SOQL Statements
    SOQL statements evaluate to a list of sObjects, a single sObject, or an Integer for count method queries.

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

    SOSL Statements   

    sObjects, 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.

    Hope this helps.

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos