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
src0010src0010 

Need help with SOQL Query (Left Outer Join)

I am trying to create a query to group our Project Billing Item (custom object) by Project (another custom object).  Below is a copy of my initial query:

 

 

SELECT Name, (SELECT Project__c, Name, Employee__c, Description_of_Work__c, Hours_Worked__c, Date__c FROM Project_Billing_Item__c) FROM Project__c

Which generates the following error when executing: "Didn't understand relationship 'Project_Item__c' in FROM part of query call.  If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name."

 

 

I also tried changing it to the following:

 

 

SELECT Name, (SELECT Project__c, Name, Employee__c, Description_of_Work__c, Hours_Worked__c, Date__c FROM Project_Billing_Item__r) FROM Project__c

 

 

....and still receiving same error message stated above.  If it helps Project Billing Item (Project_Billing_Item__c) has a Master-Detail relationship to Project (Project__c).  Some additional information in case it helps:ks

 

 

Master-Detail Options
Related To: Project
Child Relationship Name: Project_Billing_Items
Related List Label: Project Billing Items

Master-Detail Options
Related To:   Project
Child Relationship Name:   Project_Billing_Items
Related List Label:    Project Billing Items

 

 

 

Thanks for the help and if I can provide any additional information that might help just let me know!

Best Answer chosen by Admin (Salesforce Developers) 
Anand@SAASAnand@SAAS

Try the following:

 

SELECT Name, (SELECT Project__c, Name, Employee__c, Description_of_Work__c, Hours_Worked__c, Date__c FROM Project_Billing_Items__r) FROM Project__c

 

 

Check out  the following link for more information on relationship queries:

http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_calls_soql_relationships.htm

All Answers

Anand@SAASAnand@SAAS

Try the following:

 

SELECT Name, (SELECT Project__c, Name, Employee__c, Description_of_Work__c, Hours_Worked__c, Date__c FROM Project_Billing_Items__r) FROM Project__c

 

 

Check out  the following link for more information on relationship queries:

http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_calls_soql_relationships.htm

This was selected as the best answer
src0010src0010

Thanks, that did it!  Changing Project_Billing_Item__r to the plural Project_Billing_Items__r resolved the error.

PRIYANKA K2PRIYANKA K2
how to store SELECT Name, (SELECT Name FROM Job_Applications__r) FROM Position__c ?