• Bill Haack
  • 10 Points
  • Member since 2016

  • Chatter
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
  • 0
I have a Junction object name AcctContactAff which I use to create a many-to-many relationship between Contacts and Accounts and stores (among other things) the title of the person at the account.

Being new to SOQL I am really struggling to get the following to work:

SELECT Id, Name, NPI__c,
(SELECT Title__c FROM AcctContactAff__r)
FROM Contact

When I run this I get the error message: "Didn't understand relationship 'AcctContactAff__r' in FROM part of query call."

However, I can get the query to work when I do this:

SELECT Contact__r.id, Contact__r.Name, Title__c, Name
FROM AcctContactAff__c

I absolutely need to run the query from the Parent object not the Child object.

Can anyone tell me what is wrong with the first query statement?