Search code examples
salesforcesoql

Fetching person account related to a specific opportunity


I got an opportunity where I want to fetch the related person account on it

This is my soql:

SELECT Id, Name, (SELECT Id, Name FROM Opportunities WHERE Id='{pv0}') FROM Account WHERE IsPersonAccount=True

It returns all the Person Account, how can I filter it to just an specific opp record?


Solution

  • select id, name
    from account
    where id in (select accountid from opportunity where id='006...')