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
GarrettzGarrettz 

SOQL Queries / Sub-queries

I have a joint object connecting Contacts and Accounts. We are using person accounts, so the connection to contacts is really to connect to Accounts a second time. We are trying to pull the list of Accounts related to a list of contacts via this joint table.

 

I believe I need to use the child relationship name for this query. Here is the query for the person accounts

SELECT USER_NAME__C,LASTNAME,FIRSTNAME,ASSOCIATE_NUMBER__PC,ASSOCIATE_STATUS__PC,PERSONMAILINGCITY,PERSONMAILINGSTATE,PERSONEMAIL,CLIENTLIST__C,MEMBERSINCE__C,TOTENGAGEMENTS__C,TOTBILLING__C,COMENGAGEMENTS__C,ACTENGAGEMENTS__C FROM Account WHERE (RecordTypeId='012C0000000Q8EyIAK' OR RecordTypeId='012C0000000Q8ExIAK') AND ASSOCIATE_STATUS__PC!='Terminated' AND Associate_Number__PC!=null AND IsDeleted=FALSE

 When I include Clients__pr (The child relationship name for Contact [Master] to Joint Object [Child]) in the SOQL query, I get an invalid field error.

 

Essentially I am looking for a way to have a query of Accounts referenced on this joint table within a query of contacts.

 

-Thanks much, Garrett

craigmhcraigmh

Clients__pr is the name of the relationship, and doesn't specify any data to return, just the way to link to another object.

 

So the syntax would be more like this:

 

Clients__pr.Name