Development questions

How do you write a Parent-to-Child subquery on Standard Objects (Contacts) vs Custom Objects (Employees__r)?

DevelopmentEasyInfosysCognizantHCL

Use a subquery in the SELECT list with the child relationship name (plural for standard objects, __r for custom).

soql
SELECT Id, Name, (SELECT LastName, Email FROM Contacts) FROM Account
SELECT Id, Name, (SELECT Name, Salary__c FROM Employees__r) FROM Department__c

Results are nested lists: in Apex use acc.Contacts or dept.Employees__r. The relationship name comes from the lookup/master-detail field's Child Relationship Name setting.

soqlrelationshipsparent-to-child