Address__r
is the relationship name of the Address__c
to Contract__c
newAddress
is holding all the value of Address__c
from trigger.new
, So if you have a list of Address then you can use that List of Address instead of newAddress
this query will return the Contract related to all Addresses
List<Contract__c> conList = [Select Id,(Select Id from Address__r) from Contract__c where Id IN (Select Address__c from Address__c where Id IN :newAddress)];
If you want to query for single address then simply write the condition for the address in where Clause like:
List<Contract__c> conList = [Select Id,(Select Id from Address__r) from Contract__c where Id IN (Select Address__c from Address__c where Id = '0092813000vzvu1')];