Toggle Side Panel

  • Home
  • Articles
    • All Articles
    • Blogs
    • Videos
    • Infographics
  • Consultants
    • Salesforce Product Expertise
      • Top Salesforce ConsultantsTop Salesforce Consultants
      • Marketing Cloud ConsultantsMarketing Cloud Consultants
      • Service Cloud ConsultantsService Cloud Consultants
      • Experience Cloud ConsultantsExperience Cloud Consultants
      • Analytics Cloud ConsultantsAnalytics Cloud Consultants
    • Salesforce Industry Expertise
      • Non-Profit Cloud ConsultantsNon-Profit Cloud Consultants
      • Financial Service Cloud ConsultantsFinancial Service Cloud Consultants
      • Health Cloud ConsultantsHealth Cloud Consultants
      • Commerce Cloud ConsultantsCommerce Cloud Consultants
      • Manufacturing Cloud ConsultantsManufacturing Cloud Consultants
    • Salesforce Experts by Location
      • USATop Salesforce Consultants in USA
      • IndiaTop Salesforce Consultants in India
      • AustraliaTop Salesforce Consultants in Australia
      • United KingdomTop Salesforce Consultants in UK
      • CanadaTop Salesforce Consultants in Canada
  • Webinars
  • Marketplace
  • Advertise With Us
  • Contact Us
  • Discussions
More options
    Sign in Sign up
    • Home
    • Articles
      • All Articles
      • Blogs
      • Videos
      • Infographics
    • Consultants
      • Salesforce Product Expertise
        • Top Salesforce ConsultantsTop Salesforce Consultants
        • Marketing Cloud ConsultantsMarketing Cloud Consultants
        • Service Cloud ConsultantsService Cloud Consultants
        • Experience Cloud ConsultantsExperience Cloud Consultants
        • Analytics Cloud ConsultantsAnalytics Cloud Consultants
      • Salesforce Industry Expertise
        • Non-Profit Cloud ConsultantsNon-Profit Cloud Consultants
        • Financial Service Cloud ConsultantsFinancial Service Cloud Consultants
        • Health Cloud ConsultantsHealth Cloud Consultants
        • Commerce Cloud ConsultantsCommerce Cloud Consultants
        • Manufacturing Cloud ConsultantsManufacturing Cloud Consultants
      • Salesforce Experts by Location
        • USATop Salesforce Consultants in USA
        • IndiaTop Salesforce Consultants in India
        • AustraliaTop Salesforce Consultants in Australia
        • United KingdomTop Salesforce Consultants in UK
        • CanadaTop Salesforce Consultants in Canada
    • Webinars
    • Marketplace
    • Advertise With Us
    • Contact Us
    • Discussions
    Close search

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

    Tagged: Account, Contact, Integer, Lead, List, Salesforce Opportunity, Salesforce sObject, SOQL, SOSL

    • Salesforce® Discussions

      What is the difference between SOQL and SOSL?

      Posted by Shubham on April 30, 2016 at 8:29 AM

      What is the difference between SOQL and SOSL? Can somebody explain with a simple example.

      Avnish Yadav replied 7 years, 2 months ago 6 Members · 5 Replies
      • Account
      • Contact
      • Integer
      • Lead
      • List
      • Salesforce Opportunity
      • Salesforce sObject
      • SOQL
      • SOSL
    • 5 Replies
    • Nitish

      Member
      April 30, 2016 at 8:56 AM

      Hi Shubham

      Here is this:-

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

      For example, you could retrieve a list of accounts that are named Acme:

      List<Account> aa = [SELECT Id, Name FROM Account WHERE Name = 'Acme'];

      2. SOSL Statements
      SOSL statements evaluate to a list of lists of 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. 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, you can return a list of accounts, contacts, opportunities, and leads that begin with the phrase map:

      List<List<SObject>> searchList = [FIND 'map*' IN ALL FIELDS RETURNING Account (Id, Name), Contact,         Opportunity, Lead];

    • Ravi

      Member
      April 30, 2016 at 9:31 AM

      SOQL:
      SOSL:
      SOQL (Salesforce Object Query Language ) retrieves the records from the database by using “SELECT” keyword.
      SOSL(Salesforce Object Search Language) retrieves the records from the database by using the “FIND” keyword.
      By Using SOQL we can know in Which objects or fields the data resides.
      By using SOSL, we don’t know in which object or field the data resides.
      We can retrieve data from single object or from multiple objects that are related to each other.
      We can retrieve multiple objects and field values efficiently when the objects may or may not be related to each other.
      We can Query on only one table.
      We can query on multiple tables.

    • William

      Member
      July 5, 2018 at 4:00 AM

      Here is the difference between SOQL and SOSL

      SOQL -

      Only one object at a time can be searched(Search in Single object)
      Query all type of field
      It can be used in classes n triggers
      DML Operation can be performed on query results
      SOQL use when we know in Which objects or fields the data resides.
      We can retrieve data from single object or multiple objects that are related to each other.

       

      SOSL -

      Many object can be searched at a time(Search in entire organization or Database)
      Query on only email, text or phone
      It can use in classes but not in trigger
      DML Operation cannot be performed on search results
      SOSL use when we don’t know in which object or field the data resides.
      We can retrieve multiple objects and field values where the objects may or may not be related to each other.

      • This reply was modified 7 years, 5 months ago by  William.
    • Parul

      Member
      September 16, 2018 at 2:53 PM

      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

    • Avnish Yadav

      Member
      September 18, 2018 at 1:25 PM

      Hello,

      SOSL can search multiple object types, which requires multiple separate queries in SOQL, in addition, all the relevant fields are already text indexed for SOSL, but the same fields don't have DB indexes, so SOQL queries against them will be slower. If you have a lot of data, these differences will be much more apparent.

      Thanks.

    Log In to reply.

    • Public
    • All Members
    • My Connections
    • Only Me
    • Public
    • All Members
    • My Connections
    • Only Me
    • Public
    • All Members
    • My Connections
    • Only Me

    application solution

    Popular Salesforce Blogs

    SMS In Salesforce

    3 Best SMS API Providers Other Than Twilio For SMS In Salesforce

    Blog in Others, Salesforce

    Every business strives for quick and scalable communication within a few minutes. And this is obviously not possible with calls and emails. This is why…

    AppExcahge, Automate Interactions, Automated Interactions, Best SMS API, Bulk Messaging
    360 SMS APP Jun 28, 2021
    4,687  Views

    Features Your B2B Customer Portal Will Need in 2024

    Blog in Salesforce

    B2B companies are now conquering the heights of e-commerce, where providing a smooth customer experience is the only way to the top. How do you…

    B2B Commerce, B2B Customer Portal, B2B Decision-Makers, B2B Engagement, Bulk Pricing Models.
    Brimit Jan 30, 2024
    1,965  Views
    salesforce environments

    Digging Deeper Into Salesforce Environments!

    Blog in Salesforce

    As the Forcedotcom terminology goes, Environments and organizations are equivalent to one another. This article will be focusing on Salesforce Environments, their types, uses, characteristics,…

    App Testing, Custom Database Objects, Developing and Testing Applications, Development Environments, Enterprise Edition
    Algoworks Mar 30, 2020
    1,653  Views
    Footer Forcetalks logo

    support@forcetalks.com

    • twitterx

    Quick Links

    Advertise with Us

    Salesforce® Articles

    Dreamforce 2023

    Top Salesforce® Bloggers 2023

    Top Salesforce Consultants

    Get Listed

    Company

    Contact Us

    About Us

    Privacy Policy

    Terms & Conditions

    InsightHub

    Salesforce Blogs

    Salesforce Videos

    Salesforce Groups

    Salesforce Jobs

    © 2025 - Forcetalks ● All Rights Reserved

    Salesforce® is a trademark of Salesforce® Inc. No claim is made to the exclusive right to use “Salesforce”. Any services offered within the Forcetalks website/app are not sponsored or endorsed by Salesforce®.

    Try AuditMyCRM - It is a Salesforce CRM Audit tool which comprehensively scans your Salesforce org and gives you the list of errors or warnings you need to take care of.
    We use cookies to enhance your browsing experience. Please see our privacy policy if you'd like more information on our use of cookies.