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
Raksha NarayanRaksha Narayan 

SOQL query on non-related objects

Account is a parent to Object B and Object C. Object B and Object C does not have any relationship. From Object B I want to find Object C's fields(like name etc.,) using Account in a single SOQL query. Can this be achieved?
VinayVinay (Salesforce Developers) 
You can try something like below.
 
select id from Object B where Account__r.Object c.field ='test'

OR

Select Id, Name From Account WHERE Id IN (Select Account__c FROM Object__c WHERE status__c = ‘Yellow’).

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/langCon_apex_SOQL.htm
https://www.salesforcetutorial.com/soql-inner-join-outer-join-relationships-salesforce/

Thanks,
Raksha NarayanRaksha Narayan
Hi Vinay,
Here is the query I was trying.
select id,Account.Name from ObjB where Account.Name IN(select Account__c from ObjC). In the inner query I am passing the Account__c, but I want to find the value of Name field from ObjC. Is this achievable in any way?