Activity › Forums › Salesforce® Discussions › What is the difference between SOSL queries and SOQL queries in Salesforce?
Tagged: Difference, Salesforce Customization, Salesforce SOQL, Salesforce SOSL, SOQL Query, SOSL Query
-
What is the difference between SOSL queries and SOQL queries in Salesforce?
Posted by kapil on January 12, 2018 at 5:08 AMwhat is the difference between SOSL queries and SOQL queries in Salesforce?
shariq replied 7 years, 7 months ago 4 Members · 3 Replies -
3 Replies
-
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 - [adinserter block='9']
-
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
-
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.