Path To Salesforce - SOQL Overview - A Comprehensive Guide
Path To Salesforce - SOQL Overview - A Comprehensive Guide
php/courses/apex-intermediate)
Continue (https://pathtosalesforce.com/index.php/courses/integration-course)
GO TO COURSE (https://pathtosalesforce.com/index.php/courses/integration-course)
Continue (https://pathtosalesforce.com/index.php/courses/lwc-course)
GO TO COURSE (https://pathtosalesforce.com/index.php/courses/lwc-course)
Continue (https://pathtosalesforce.com/index.php/courses/experience-cloud)
Exercises ( Quizzes)
Continue (https://pathtosalesforce.com/index.php/exercise)
GO TO COURSE (https://pathtosalesforce.com/index.php/exercise)
https://pathtosalesforce.com/~vtqkyvmy/index.php/58-salesforce-articles/369-soql-overview-a-comprehensive-guide 12/8/24, 11 33 PM
Page 3 of 6
:
SOQL Overview: A Comprehensive Guide
(/~vtqkyvmy/index.php/58-salesforce-articles/369-soql-
overview-a-comprehensive-guide)
Written by Engin Basturk (/~vtqkyvmy/index.php/component/contact/contact/1?Itemid=958)
Common Keywords
SELECT
GO TO TOP
Use to select records from your Salesforce Org.
(/~VTQKYVMY/INDEX.PHP/58-
FROM SALESFORCE-ARTICLES/369-
Identify the Salesforce objectSOQL-OVERVIEW-A-
from which records are being retrieved.
WHERE COMPREHENSIVE-GUIDE#TOP)
Filter records that meet specific conditions.
AND
Combine multiple filter conditions that all must be true.
OR
Combine multiple filter conditions where only one must be true.
LIMIT
Specify the maximum number of records returned.
ORDER BY
Specify the order of the records being returned.
SOQL Examples
Basic Queries
Retrieve all accounts with the id, name, and website fields:
https://pathtosalesforce.com/~vtqkyvmy/index.php/58-salesforce-articles/369-soql-overview-a-comprehensive-guide 12/8/24, 11 33 PM
Page 4 of 6
:
SELECT Id, Name, Website FROM Account
Relationship Queries
Child to Parent
Parent to Child
Retrieve all child contacts with the name and email of each account:
SELECT Id, Name, (SELECT FirstName, Email FROM Contacts) FROM Account
SOQL in Apex
Retrieving Records
Retrieve accounts and store the values in a list:
Opportunity opp = [SELECT Id, Name, Amount FROM Opportunity LIMIT 1];
This guide serves as a handy reference for understanding and utilizing SOQL in Salesforce. Whether
you're writing basic queries or incorporating them into Apex code, mastering SOQL will enhance your
ability to manage and manipulate data within Salesforce effectively.
Prev (/~vtqkyvmy/index.php/58-salesforce-articles/370-salesforce-reports-and-
dashboards)
Next (/~vtqkyvmy/index.php/58-salesforce-articles/366-22-ways-to-share-records-
in-salesforce)
https://pathtosalesforce.com/~vtqkyvmy/index.php/58-salesforce-articles/369-soql-overview-a-comprehensive-guide 12/8/24, 11 33 PM
Page 5 of 6
:
https://pathtosalesforce.com/~vtqkyvmy/index.php/58-salesforce-articles/369-soql-overview-a-comprehensive-guide 12/8/24, 11 33 PM
Page 6 of 6
: