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
Tanner RussellTanner Russell 

SOQL Query Parent to child

I want to compare 2 fields in child objects of a parent in a single query I thought the query below might do it by readding the select to it but it does not like that. How can I do this if its possible? I am comparing a field called block_number__c on each object, Thanks (possibly using the Not In could work?)

select id, (Select id, property_name__r.name, block_number__c from Spaces__r where Occupied__c = true or occupied_rr__c = true limit 1), (Select id, block_number__c, property_name__c from contacts) from account where (Select id, block_number__c, property_name__c from contacts).block_number__c != (Select id, property_name__r.name, block_number__c from Spaces__r where Occupied__c = true or occupied_rr__c = true limit 1).block_number__c