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
TerminusbotTerminusbot 

Parent to Child Query

     Parent Object: Account 
     Child Object:Sagitta Sequences
         Master detail field to Accounts: Account
         API Name: Account__c
         Child Relationship Name: Sagitta_Sequences

I am trying to run a query from the account object and get the Sagitta Sequences Name field. This works to return the records that have the child record associated. 
 
Select id, name
FROM Account 
WHERE id in (Select account__c From Sagitta_Sequence__c)
I am trying to include the Sagitta_Sequence__c.Name from the child object but I keep getting an error. I was trying this:
 
Select id, name, Sagitta_Sequence__c.Name
FROM Account 
WHERE id in (Select account__c From Sagitta_Sequence__c)

Thanks for the help. 
 
SalesFORCE_enFORCErSalesFORCE_enFORCEr
I think you want something like this:
Select Id, Name, (Select Name from Sagitta_Sequence__c) from Account where id in (Select account__c From Sagitta_Sequence__c)
Sitarama MurthySitarama Murthy
hi,
try this query:

" Select id,name,(Select Name from Sagitta_Sequence__c )
  From Account
  Where Id In(Select account__c From Sagitta_Sequence__c)​ "
TerminusbotTerminusbot
Thanks for the replies. Here is a little more context. I have the Map that works but when I try to add in the Sagitta_Sequence__c.Name it gives me an error. I have placed in BOLD what I am trying to add to this map. 
 
accounts = new Map <ID, Account> 

([Select ID, Name,BillingStreet,BillingCity,BillingState,
                                         BillingPostalCode,Phone,Email__c, 
                                         Client_Code__c, SagittaID__c, RecordType.Name,  
                                         Sagitta_Sequence__c.Name 
                                         from Account where ID in :ids and recordtypeid in (Select Id from                         RecordType where sobjecttype = 'Account')
                                         and ID in (Select account__c FROM Sagitta_Sequence__c)
                                         ]);

 
TerminusbotTerminusbot
This works in query editor. I just can't add it into my map query in Apex. 
 
SELECT (SELECT Name FROM Sagitta_Sequences__r ) FROM Account

 
SalesFORCE_enFORCErSalesFORCE_enFORCEr
Why can't you add it into your map query? Is it throwing any error?
TerminusbotTerminusbot
Yes. I am getting an error in my Map query. 
SalesFORCE_enFORCErSalesFORCE_enFORCEr
What is the error?