Salesforce Object Query language SOQL syntax is similar to SQL language. In SOQL, SELECT statement is used to specify the source object to retrieve data.
SELECT fields FROM Object WHERE Condition Ordering LIMIT FOR VIEW Or FOR REFERENCE OFFSET UPDATE VIEWSTAT
From the above SOQL syntax we have many things to observe and understand. SELECT, fields, FROM and Object are required and all others are optional. Let us understand in detail.
|Fields||This denotes the API name of the fields of an object|
|Object||This denotes the custom object or standard object.|
|Condition||This is use to filter records and it is optional.|
|Ordering||This is used for ordering the results and it is optional in the query.|
|Limit||It is used to limit the number of fetched records.|
|FOR VIEW||This displays last viewed date for fetched records.|
|FOR REFERENCE||This displays last reference date for fetched records.|
|OFFSET||It is used to to fetch the starting row.|
|UPDATE VIEW STATE||This updates the article’s view statistics for fetched records.|
The API names of the fields are used in the SELECT statement. In our upcoming Salesforce developer tutorials we will learn about various SOQL syntax like Condition expression syntax using WHERE clause and field expression syntax.
In this Salesforce Developer Tutorial, we learned about Apex SOQL syntax.