
I tried
select Id, Title__c,
(SELECT Id, Name FROM Attachments)
from My_Object__c
But how can I get the ContentDocument Id and ContentVersion Id using the query? I am not sure how to proceed. Can I try something like this
select Id, Title__c,
(SELECT ContentDocumentId FROM ContentDocumentLink),
(select id from contentversion where contentdocumentid=ContentDocumentId and isLatest=true)
from My_Object__c
I know the above query is wrong and I don't see how to use the ContentDocumentId in the where condition of ContentVersion query. I am confused. Please help.

Hi,
Select id, ContentDocumentId, ContentDocument.LatestPublishedVersionId from ContentDocumentLink where LinkedEntityId IN (some list of obj Ids) gets you all ContentDocuments and the latest version Id
Thanks,
Nagendra.