Relationship Queries in SOQL - Parent To Child
VINAY MADHAV???
Salesforce CPQ || Billing || Revenue Cloud Developer @ LTIMindtree || 9X Certified ||????Trailhead Ranger || Lets Grow Together ||
Parent To Child Relationship :
In Parent To Child relationship, we write an?Inner Query or Sub Query?in the Main Query to fetch the records of the Child.?
1.?Standard Object:-
List<Account> accList = [ SELECT Name , NumberOfEmployees , (SELECT firstName , lastName , Phone FROM Contacts) FROM Account ];
领英推荐
2. Custom Object:-
List<Student__C> stdList = [ SELECT Name, Email_ID__c, Roll_Number__c, Student_Address__c, (SELECT Name, Percentage_Marks__c, Total_Marks__c FROM Marks__r ) FROM Student__c ];
?Note:-??In Custom Object,?Child Relationship Name?must be written with suffix?__r??while in Standard Object simply use the?Child Relationship Name.
Salesforce Administrator & Developer | Salesforce Industries | 10x Salesforce Certified | Trailhead Double Ranger ????
2 年A Student is a custom object, So your List definition must be "List<Student__c>"