How to Relationship Query in Salesforce?

on

|

views

and

comments

Table of Contents

Recap

In the previous blog post, we talked about what is SOQL and how we can perform the basic SOQL in Salesforce using the Developer Console.

Introduction

Here in this blog post, we will talk about how we can work on the relation ship queries in Salesforce.

Relationship queries are very important as we will be using these SOQLs in our day to day development duties.

SOQL Continue

  • HAVING
    • Having Count(Id) > 1
  • Relationship queries: child-to-parent
    • Contact ( Child )
      • Account
    • Opportunity ( Child )
      • Account
    • Case ( Child )
      • Account
      • Contact
  • Relationship queries: parent-to-child
    • Account (Parent)
      • Contact
      • Opportunity
      • Case

Watch Complete Video

Assignments

  • List All the Contact Records with Account Name, Rating, and Industry
  • Query on the Account object and also query all the related Contact, Case, Order, and Opportunities
  • Create 3 Custom Objects
    • An invoice that is related to the Account
    • An Invoice Line Item object that is related to the Invoice
    • A payment that is related to the Account
    • Now Query on Invoice Records to Query the Related Account Information and Also all the related Invoice Line Items
    • Note: – Please create the required records for these objects
  • Query All the Contact Record that does not have any Account Related To
  • Query All the Contact Records that are related to Account Record
  • Query All the Account Record that does not have any contact
  • Query All the Account Record that does have min one Contact Record
  • Query the Invoice Record, its Related Account, and Account Related Parent Account Record
  • Query the Invoice Line Item Record, its Related Invoice, Invoice Related Account, and Account Related Parent Account Record
  • Write a SOQL Query to Show the MAX amount from the opportunity
  • Write a SOQL Query to identify the duplicate records by Name & Email
  • Write a SOQL Query to display the count of Accounts for every Industry

Resources

Amit Singh
Amit Singhhttps://www.pantherschools.com/
Amit Singh aka @sfdcpanther/pantherschools, a Salesforce Technical Architect, Consultant with over 8+ years of experience in Salesforce technology. 21x Certified. Blogger, Speaker, and Instructor. DevSecOps Champion
Share this

Leave a review

Excellent

SUBSCRIBE-US

Book a 1:1 Call

Must-read

How to Utilize Salesforce CLI sf (v2)

The Salesforce CLI is not just a tool; it’s the cornerstone of development on the Salesforce Platform. It’s your go-to for building, testing, deploying, and more. As one of the most important development tools in our ecosystem

Save the day of a Developer with Apex Log Analyzer

Table of Contents What is Apex Log Analyzer? Apex Log Analyzer, a tool designed with Salesforce developers in mind, is here to simplify and accelerate your...

Salesforce PodCast

Introduction Hey Everyone, Welcome to my podcast, the first-ever podcast in India for Salesforce professionals. Achievement We are happy to announce that we have been selected as Top...

Recent articles

More like this

LEAVE A REPLY

Please enter your comment!
Please enter your name here

5/5

Stuck in coding limbo?

Our courses unlock your tech potential