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
Ramesh RageRamesh Rage 

SOQL query to get Custom Object records with Attachmnets

Need a SOQL query to get the records with its attachmnets alone, don't need records with out attachmnets.
Anoop yadavAnoop yadav
Hi,

You should use inner query to do this.
check the below link.
https://developer.salesforce.com/forums/ForumsMain?id=906F000000090ugIAA
SarfarajSarfaraj
List<Id> attIds = new List<Id>();
for(Attachment att : [Select Id, ParentId From Attachment])
    attIds.add(att.ParentId);
List<Account> acc = [Select Id, Name, (Select Id From Attachments) From Account Where Id in :attIds];