function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Girish Reddy 52Girish Reddy 52 

In a SOQL query when should we use plural word and singular words to fetch Standard Objects I'm little confused about this, can anyone please clear my doubt

for example: here Opportunites & Opportunity is used

1. List<Account> Aop = [Select Name (Select Name, StageName From Opportunites) From Account];

2. for(Opportunity opp: acc.opportunity){
        system.debug('Child '+ opp.Stagename);
   }
    
 
Best Answer chosen by Girish Reddy 52
VinayVinay (Salesforce Developers) 
Hi Girish,

You need to use object API name like Account/Contact etc when you are query directly.  However, if you are dealing with relationships like fetch all contacts from Account, then we need to go for Contacts relationship name Eg. Contacts.

Check below references.
https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_relationships_and_custom_objects.htm
https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_relationships_understanding.htm

Please mark as Best Answer if above information was helpful so that it can help others in the future.

Thanks,