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

You should use inner query to do this.
check the below link.
List<Id> attIds = new List<Id>();
for(Attachment att : [Select Id, ParentId From Attachment])
List<Account> acc = [Select Id, Name, (Select Id From Attachments) From Account Where Id in :attIds];