SOQL Includes, Excludes Operators

SOQL Includes, Excludes Operators: In our previous salesforce Tutorial we have learned about SOQL ORDER BY clause. In this salesforce training tutorial we are going to learn about SOQL INCLUDES, EXCLUDES Operators in salesforce.

SOQL Includes and excludes operators  are mainly used to filter multipicklist field values in salesforce. These operators are used for only multipicklist values. Multipicklist values are those whose have more than one picklist values .

For example a student must have many skills to get a job (salesforce, Java, C, C#, ORACLE etc).

  • SELECT name, country__c, Student_skills__c FROM Student__C .
SOQL Includes, Excludes Operators

SOQL Includes, Excludes Operators

From above SOQL statement all the records from Student object has retrieved.

INCLUDES Operator

Includes operator is used to filter and retrieve the data that contains any of the specified values in SOQL statement.

  • SELECT name, country__c, Student_skills__c FROM Student__C WHERE student_skills__C INCLUDES (‘salesforce’).
SOQL Includes, Excludes Operators

SOQL Includes, Excludes Operators

From above SOQL INCLUDES operator statement we filtering the data whose student skills is equal to ‘salesforce’.

Excludes Operator

  • SELECT¬†name, Country__C, Student_skills FROM Student__c WHERE student_skills EXCLUDES (‘salesforce’)
SOQL Includes, Excludes Operators

SOQL Includes, Excludes Operators

From above SOQL statement we fetching the data whose student will have no salesforce skills. condition must be written in single quotations and braces as shown above.

Comments on this entry are closed.