I have list values from child 1 from the below query child1list=[select name,id,parent__c,field11,field12 from child1__c]
I have list of child2 child2list=[select id,name,parent__r,parent__r.name,field21,field22 from child2 where parent__c in : parentids]
But I Have to update child1 fields in for loop as below accessing from child2 via parent
for(child1__c child1 : child1list){
child1list.field11=child2list[].field21;//how to associate the related record here child2list[]
}
Can someone suggest me the approach? (I have child1 associated to parent1 which has only one child2)parent and child2 has master detail relationship too. parent and child lookup relationship. so here from child1 I have to get child2 record that which is associated to parent(one parent--one child2)