In our previous salesforce tutorial we have learned about the Alias notation in SOQL. In this salesforce training tutorial we are going to learn about the WHERE class in SOQL.
What is WHERE clause in SOQL ?
WHERE clause is also called as Conditional Expression. WHERE clause is used to filter the retrieved data.
When ever if we want to filter data from a set of object records we use WHERE clause in SOQL. This WHERE clause filters the data based on the given Condition or Criteria. Basically when WHERE clause in SOQL statement is used WHERE clause is followed by some comparison operators and Logical Operators like IN operator, NOT IN operator, INCLUDES operator, EXCLUDES Operator.
Let us see an example on WHERE clause.
- SELECT firstname, lastname FROM Contact WHERE firstname != null
From above SOQL statement we are fetching data From Standard object called “Contact”. We are using conditional expression “WHERE” to filter the retrieved data from Contact object. Preceding WHERE we have used != operator to filter the data firstname which is not null.
Let us see another example to understand WHERE clause in SOQL.
- SELECT Firstname, Lastname FROM Contact WHERE lastname = ‘Adarsh’
From SOQL Statement we fetching data from Contact whose first name is “Adarsh”. In SOQL statements text words are mentioned with ‘ ‘.
In our next salesforce tutorial we are going to learn about the comparsion operators in salesforce SOQL statements.