What is the basic SOQL statement?
[SELECT fieldNames FROM objectName]
What are the optional SOQL clauses we can use?
What does the WHERE clause do?
it’s a filter for which records we want to return
List edgeAccs = [
SELECT Name
FROM Account
WHERE Name = ‘Edge Communications’];
What does the WITH SECURITY_ENFORCED clause do?
What are the two main SOQL return types?
What is the purpose of Variable Binding in SOQL?
String accountName = ‘Edge Communications’;
List edgeCommunications = [
SELECT Id
FROM Account
WHERE Name=:accountName]
What are the six aggregate functions that we can use in SOQL queries?
NOTE: when we write a SOQL query that only contains the COUNT function in its SELECT clause (without an argument) and no grouping, the return type of the query will be Integer
Integer numOfContacts = [SELECT COUNT() FROM Contact];
What is the purpose of the get() method in AggregateResult?
the AggregateResult class has a get() method that we use to retrieve values because we can’t reference any fields on an AggregateResult through dot notation
What is the FORMAT function?
the FORMAT function applies formatting corresponding to a user’s locale to standard/custom number, date, time, and currency fields
What is the Date function?
date functions allow us to filter or group results by specified dates
Child-to-Parent Queries
List cons = [SELECT Id, Account.Name FROM Contact];List ties = [SELECT Id, Star_Destroyer__r.Name FROM Tie_Fighter__c];
Parent-to-Child Queries
What are SOQL for loops used for?
SOQL for loops are used to avoid governor limits on heap size and the number of queries executed