I'm trying to query using a very basic line of code. I have a lookup relationship from Account to a custom object (1:1 or 1:many). Below is the query;

SELECT id, (SELECT channel__r.name,channel__r.account_cohort__c From channel__r) from Marketplace__c

Can anyone help me update this code. Essentially I want the custom object marketplace__c with fields from the account that is a lookup field on the marketplace object. For some reason, the account object is referenced as channel__r on the marketplace.

1 Answer 1


To query a child, you use:

SELECT (SELECT Field1, Field2,... FROM Children) FROM Parent

To query a parent, you use:

SELECT Parent.Field1, Parent.Field2,... FROM Child

Since Marketplace__c has a field named Channel__c that refers to the Account object, you need to use the latter version:

SELECT Channel__r.Name, Channel__r.Account_Cohort__c FROM Marketplace__c
  • I tried that and keep getting the error I was receiving before: Error at row: 1: column: 30. Didnt understand relationship 'marketplace__c" in from part of query call. Commented Jun 7, 2021 at 14:43
  • @AndreasPappas What is the exact query?
    – sfdcfox
    Commented Jun 7, 2021 at 15:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .