
Select Id FROM Contact WHERE Name LIKE ‘N%’ AND MailingState =’California’

Select ID, Name from Lead WHERE email = you want get all contact where name start with ‘N’ and state is’California’ So, if you we want to get all the Leads from your account where the email address equals = you would use the following SOQL statement: The query can be broken into following logical units:Ĭondition Expression Syntax (WHERE Clause) SELECT fieldList FROM object LIMIT number_of_rows SOQL uses the SELECT statement combined with filtering statements to return sets of data, which can optionally be ordered: While writing query one have to combine SELECT command with a list of fields to retrieve as well as the conditions for selecting rows. Hence you must specify an exact field you want to get the information about. It will help you in retrieving and manipulating data, In this you can’t specify * as for all the fields that are used for other SQL languages. SOQL can be used with Apex, Visualforce and Schema explorer of IDE.

SOQL is similar to the SELECT statement in the widely used Structured Query Language (SQL) but is specifically designed for Salesforce.

Salesforce Object Query Language(SOQL) is used to search your organization’s data for specific information.
