SOQL Logical and Comparison Operators - SOQL Basics | Salesforce Funda

 Comparison operators in SOQL are used to compare a value with another value to return TRUE or FALSE.


   Operator

Description

=

Equals

!=

Not Equals

< 

Less than

        <=         

Less than or equal to

> 

Greater than

>=

Greater than or equal to

LIKE

LIKE


SOQL Syntax :-


//equal
Select Id, Name From Account Where Industry ='Media'
//not equal
Select Id, Name From Account Where Phone != null
//less then 
Select Id, Name From Account Where CreatedDate < 2023-01-01T 00:00:00Z
//greater then 
Select Id, Name From Account Where CreatedDate > 2020-01-01T 00:00:00Z
//less then equal to
Select Id, Name From Account Where CreatedDate <= 2023-01-01T 00:00:00Z
//greater then equal to
Select Id, Name From Account Where CreatedDate >= 2020-01-01T 00:00:00Z
//like
Select Id, Name From Account Where Name like '%Sovil%'

Logical Operator :- 

And :-

Logical Operator “AND” is used to retrieve the records when all the conditions in SOQL statement is satisfied. If any  of the condition in SOQL statement is not satisfied records will not be retrieved

SOQL Syntax :-

//And 
select Id, Name from Account Where Industry='Media' and Name like '%Sovil%'
OR :-
Logical Operator “OR” is used to retrieve the records when any one of the conditions in SOQL statement is satisfied. If any of the condition in SOQL statement is not satisfied records will not be retrieved

SOQL Syntax :-


//Or ==> first condtion run first
select Id, Name, Industry from Account Where Industry='Media' Or Industry = 'Technology
Feature :-