Salesforce Object Query Language(SOQL) - Part 2

I will discuss some other SOQL statement that will help you in development over force.com Apex. Hope you guys read my first blog on SOQL Statement.

SOQL SELECT Syntax:

  • Operator in SOQL Query(Like,Equals,Not Equals,IN,NOT IN)
  • NULL in SOQL Query
Operator in SOQL:

Let's start one by one

LIKE :

The LIKE operator in SOQL is similar to the LIKE operator in SQL; it provides a mechanism for matching partial text strings and includes support for wildcards.

Example:

SELECT ID,Name,AccountNumber FROM Account where name like 'United%'

Equals (=):

Expression is true if the value in the specified fieldName equals the specified value in the expression.

Example:

SELECT ID, Name, AccountNumber FROM Account where AccountNumber ='CD355119-A'
SELECT ID, Name, AccountNumber FROM Account where ID='0019000001CH2q5AAD'


Not Equals (!=)

Expression is true if the value in the specified fieldName does not equal the specified value.

Example:

SELECT ID, Name, AccountNumber FROM Account where AccountNumber !='CD355119-A'

IN & NOT IN:

The value equals any one of the specified values in a WHERE clause.IN and NOT IN must be in parentheses. String values must be surrounded by single quotes.

Example:

SELECT ID, Name, AccountNumber FROM Account where AccountNumber IN ('CD439877','CC947211')
SELECT ID, Name, AccountNumber FROM Account where AccountNumber
NOT IN
('CD439877','CC947211')

NULL in SOQL Query

Search null values by using the null keyword. Use null to represent null values in SOQL queries.

Example:

SELECT ID, Name, AccountNumber FROM Account where AccountNumber=null

I will share you all other SOQL statement that will help you to start development on FORCE.COM.
Ebook Download
View all
Learn
View all