• mattjones99
  • NEWBIE
  • 0 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 0
    Replies

Let's say I have two objects, Parent and Child, where Child is a related list of Parent.  

I can write a query to get all children named 'One' from all parents.  And this works.

SELECT Name, (SELECT Name FROM Child__r WHERE Name = 'One') FROM Parent__c

But, what if I wanted to get all children with the same name as their parent?  

I think this would look something like:  

SELECT Name, (SELECT Name FROM Child__r WHERE Name = Parent__r.Name) FROM Parent__c

But this is always returning a malformed query exception where Parent__r is an unexpected token.  Is it possible to do what I'm trying to do?  Or do I have to get the parents, then make a separate query for each parent to get the children that match that parents' name?