SOQL is a query language that’s similar to SQL but designed for Salesforce data. To query data using Salesforce APIs, create a SOQL statement that defines the information you want to search for.
SOQL Statement Structure
The basic structure of a SOQL statement resembles this example.
SELECT _one or more fields_
FROM _an object_
WHERE _filter statements_
ORDER BY _optional sorting rules to apply to the query_
LIMIT _the maximum number of results to return_
For example, this SOQL query returns the value of the Id, FirstName, LastName, and Country fields for all contacts where the value of the MailingCountry field is NG. Results are returned in ascending order by LastName, and then in ascending order by FirstName. The maximum number of results returned is 25.
SELECT Id, FirstName, LastName, MailingCountry
FROM Contact
WHERE MailingCountry = 'NG'
ORDER BY LastName ASC, FirstName ASC
LIMIT 25